필터 지우기
필터 지우기

Storing the absor function into my code gives ABSURD error

조회 수: 3 (최근 30일)
farzad
farzad 2020년 3월 20일
댓글: farzad 2020년 3월 21일
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 ?

채택된 답변

Rik
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
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.
farzad
farzad 2020년 3월 21일
You are right Walter ! Thank you so much Rik ! the problem was the structure of where to write the end !
I was accumulating the 4 ends at the bottom of the scripts not right after each function

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by