Why does any error appear according to complex of a function?
Ältere Kommentare anzeigen
for i=1:numel(xSMp)
ySMp(i)=SMp(xSMp(i));
end
In an assignment A(I) = B, the number of elements in B and I must be the same. This error message appears if the function SMp(x) is complex. In other applications, I have used the same, and these have worked good
5 Kommentare
Jan
am 18 Jun. 2018
Please post some example data, which reproduce the problem.
Terman Frometa-Castillo
am 18 Jun. 2018
Bearbeitet: Jan
am 19 Jun. 2018
Jan
am 19 Jun. 2018
We still cannot reproduce the problem due to missing inputs and global variables. I guess, that the function does not reply a scalar, but this is not a problem of the complex values.
Terman Frometa-Castillo
am 19 Jun. 2018
Jan
am 19 Jun. 2018
Global variables are a very bad programming practice, which makes it hard to debug. 1. Avoid globals. 2. Use the debugger to step through your code line by line to find out, what's going on.
Antworten (2)
Guillaume
am 19 Jun. 2018
0 Stimmen
global variables are a major source of bugs and it is very hard to track who creates or modify them. Avoid global variables.
Your SMp function uses a global variable called Max (bad name as well, too close to the max function). I cannot see any function in your GUI that actually assigns a value to that global. I would wager that Max is a vector that has been set at some point and forgotten.
Note that there is a Max_Callback function that sets a value to a Max variable but since that Max is not declared global, that value is forgotten as soon as the callback finishes.
In any case, the best thing to do is to put a breakpoint on line 220 of your SMP function and look at the values of your global variables. One of them must be a vector for you to get your error.
Terman Frometa-Castillo
am 19 Jun. 2018
0 Stimmen
Kategorien
Mehr zu Structures finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!