Page 1 of 1

How to call a function which is in another program MATLAB

Posted: Mon Mar 06, 2017 12:56 pm
by Charles
I write this in my main program

Code: Select all

[C,rows,cols,entries] = Matrix('C.txt')
Matrix fuction is in another program Matrix.m and I want to call it.

I get this error :

Code: Select all

Undefined function or variable 'Matrix'.

Error in (line 19)

[C,rows,cols,entries] = Matrix'C.txt')
Can you please tell me how to fix it ?

Re: How to call a function which is in another program MATLAB

Posted: Thu Mar 09, 2017 8:21 am
by theenggprojects
You should place your Main file and the function file in the same folder otherwise you can't call function files in the Main File.

Moreover, another thing I just checked is that you are missing the bracket sign in below code:

Code: Select all

[C,rows,cols,entries] = Matrix'C.txt')
So, you should add this small bracket too.

Re: How to call a function which is in another program MATLAB

Posted: Fri Mar 10, 2017 12:40 pm
by Charles
theenggprojects wrote:
Thu Mar 09, 2017 8:21 am
You should place your Main file and the function file in the same folder otherwise you can't call function files in the Main File.

Moreover, another thing I just checked is that you are missing the bracket sign in below code:

Code: Select all

[C,rows,cols,entries] = Matrix'C.txt')
So, you should add this small bracket too.
thanks for the code dear