Storing the absor function into my code gives ABSURD error

1 vue (au cours des 30 derniers jours)
farzad
farzad le 20 Mar 2020
Commenté : farzad le 21 Mar 2020
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 ?

Réponse acceptée

Rik
Rik le 20 Mar 2020
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 commentaires
Walter Roberson
Walter Roberson le 21 Mar 2020
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 le 21 Mar 2020
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by