Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Integrating C#/Matlab !! ?? Errors !
Posted:
Jul 13, 2011 8:00 AM
|
|
I used the Matlab help to integrate Matlab functions in C#. I was successful in making an assembly for the m-file given below !
read_aud.m: ---------------------------------------------------------------------------------------------------------------- % Reading the wav-file .... % 'a' is a string that represents the path of the *.wav file function read_aud(a) [y f] = wavread(a);
t = 0:1/f:(length(y)-1)/f; plot(t, y), grid on;
n = length(y)-1; t1 = 0:f/n:f; fou = abs(fft(y)); figure, plot(t1,fou), grid on; ---------------------------------------------------------------------------------------------------------------- This is the main C# code !
using System; using MathWorks.MATLAB.NET.Utility; using MathWorks.MATLAB.NET.Arrays; using readAud;
[assembly: NativeGC(true, GCBlockSize = 25)] // Set native memory management block size to 25 MB.
namespace readAud { /// <summary> /// This application demonstrates plotting a .wav file in /// time-domain and its FFT also ! /// </summary> class readAud { #region MAIN
/// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { try { string url = @"\\test.wav"; // Create a new signalAndFft object signalAndFft plotter = new signalAndFft();
// Casting a string to an MWCharArray which is to be passes as an argument in read_aud.m plotter.read_aud((MWCharArray)url);
Console.ReadLine(); // Wait for user to exit application }
catch (Exception exception) { Console.WriteLine("Error: {0}", exception); } }
#endregion } }
The exception that I got was : Could not load type 'readAud.signalAndFft' from assembly 'readAud, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
What could be the reason ??
The project can be downloaded from "http://www.mediafire.com/download.php?reby2cc6hdglsir"
Please help !
|
|
|
|