Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Integrating C#/Matlab !! ?? Errors !

Subject: Integrating C#/Matlab !! ?? Errors !

From: Animesh Pandey

Date: 13 Jul, 2011 12:00:31

Message: 1 of 1

I used the Matlab help to integrate Matlab functions in C#. I was successful in making an assembly for the m-file given below !

% 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>
        static void Main(string[] args)
                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

                Console.ReadLine(); // Wait for user to exit application

            catch (Exception exception)
                Console.WriteLine("Error: {0}", exception);


The exception that I got was :
Could not load type 'readAud.signalAndFft' from assembly 'readAud, Version=, Culture=neutral, PublicKeyToken=null'.

What could be the reason ??

The project can be downloaded from

Please help !

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us