Storing the absor function into my code gives ABSURD error
2 次查看(过去 30 天)
显示 更早的评论
Hi all
I was trying to store the absor function in my code, to avoid calling it from a separate m file. Strangely it worked fine as a separate m file but as soon as copying it into my code, It seems that matlab doesn't like it's last three functions and says they might not be used. when I try to run the code, it gives the error on dealr function.
Error: Undefined function 'dealr' for input arguments of type 'double'.
I still have not changed the way I use the absor function in the code as I wrote when I was calling it as an external mfile :
[regParams,Bfit,ErrorStats]=absor(A1,A2);
I don't know whether I should introduce
funx= @absor
and if so, how to change the function expression and still : what is that error , and if the function is not actually dealr but deal and there is a typo in the function name
but still : why was it working fine as a separate m file ?
0 个评论
采纳的回答
Rik
2020-3-20
You need to close all your functions with the end keyword or none of them. Within the same file you cannot mix the two styles. My guess is that the file you pasted this in did already use end keywords for each function, and this absor function doesn't.
7 个评论
Walter Roberson
2020-3-21
You are mistaken, farzad.
I put the following code into a script:
N = 10;
A = randn(2, N);
B = randn(2, N);
[regParams,Bfit,ErrorStats]=absor(A,B);
disp(regParams)
disp(Bfit)
disp(ErrorStats)
followed by the code for absor taken from the File Exchange, except that I added an end statement corresponding to every function statement. The results looked fine to me.
Note that you have four functions for which end must be added.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Testing Frameworks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!