"Struct contents reference from a non-struct array object" error in fzero
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Shlomo
am 26 Okt. 2016
Kommentiert: Shlomo
am 26 Okt. 2016
A bit of background: I have a few versions of Matlab on my computer (2012a and 2014a). I recently started having problems with commands that used to work, an example being fzero. When I run it, I get the error "Struct contents reference from a non-struct array object." Strangely, this happens both on my primary version (2014a) and backup version (2012a). I also installed 2016a to test it and it's also giving the same error.
>> X = fzero(@(x) sin(3*x),2)
Struct contents reference from a non-struct array object.
Error in fzero (line 167)
error(message(errStruct.identifier));
Does anyone have any idea what's going on or how to fix this?
1 Kommentar
Akzeptierte Antwort
Steven Lord
am 26 Okt. 2016
Make sure you're calling the version of the fzero function included in the release of MATLAB that you're using.
which -all fzero
Also make sure you haven't overloaded the fcnchk function.
which -all fcnchk
Weitere Antworten (1)
Jan
am 26 Okt. 2016
You can set a breakpoint in the "[FunFcn,errStruct] = fcnchk(..." line of fzero (should be line ~165 - I have another Matlab version). Then step into fcnchk and check, what's going on there. It this the function inside the folder \funfun\ ?
If not, it is most likely a user-defined function (as Steven has mentioned before). Avoid shadowing built-in function and add user-defined paths at the bottom of the Matlab path only. See http://de.mathworks.com/matlabcentral/fileexchange/27861-uniquefuncnames for a tool to identify user-defined functions, which accidently shadow builtin functions.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!