- Post the relevant code by copy&paste, such that even typos are replicated. Pseudo-code in the forum reduces the chance to find the error.
- Copy the complete error message including the line, which causes the error.
using a function in another m file
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I would like to know how you can use a function in another function.
e.g // function [ gam, alfa, beta] = att(L) should make use of the funciton s2abcd.m
abcd=s2abcd(data,50);
A= abcd(1,1,:);
I need to use that A matrix in another m file gam= cosh(A)/L; alfa=real(gam);
In C++ it can be done easily with include function but I dont know how you can do that in Matlab
Thanks in advance
1 个评论
Jan
2012-7-9
Your comment to Luffy's answer shows, that your problem does not concern the access of the function at all. Therefore I strongly recommen to follow the standard procedure:
回答(2 个)
Luffy
2012-7-9
Just make sure the m-files in which both function & subfunction are in same directory.
Jan
2012-7-9
As long as the other M-function is stored in a folder, which belongs to the Matlab PATH, or in the current folder (see cd command), you can calling the function works by using its name - as expected.
For adding a user-defined folder to the path type pathtool to the command window, or open the corresponding menu.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!