How to call a function which is in another program MATLAB

You can post your problem related to MATLAB Projects here. We will try our best to help you out.
Post Reply
Charles
Posts: 20
Joined: Sat Feb 18, 2017 7:12 am

How to call a function which is in another program MATLAB

Post by Charles » Mon Mar 06, 2017 12:56 pm

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 ?

theenggprojects
Site Admin
Posts: 25
Joined: Tue Feb 07, 2017 12:51 pm

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

Post by theenggprojects » 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.

Charles
Posts: 20
Joined: Sat Feb 18, 2017 7:12 am

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

Post by Charles » Fri Mar 10, 2017 12:40 pm

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

Post Reply