Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

"Attempt to reference field of non-structure array" error in cell2mat function

1 vue (au cours des 30 derniers jours)
Sam136
Sam136 le 26 Juin 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
In my dynamic programming code, all values in each step are scalar except one which is a cell. This cell is generated in a main code and the dynamic programming uses this cell in another function, but I get this error: "Attempt to reference field of non-structure array". Any help?

Réponses (1)

Image Analyst
Image Analyst le 26 Juin 2015
You make it really difficult to do without code. As far as I know, only Walter had the Mind Reading Toolbox so far. Until the rest of us get it, read this http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Chances are you're doing something like
value = myStruct.myField;
and the variable myStruct of yours is not a structure, and so has no fields. So you can't reference the .myField field of it. If you had posted the complete error message ( ALL the red text), instead of just a small snippet excerpted from it, then you'd probably have your answer by now.
  2 commentaires
Sam136
Sam136 le 26 Juin 2015
Thanks for you comment. First, the reason that I didn't copy my code was that it is very long code and I don't know which part of my code can help. Second, here is the whole error:
Attempt to reference field of non-structure array. Error in dpm>dpm_boundary_line_lower (line 1018) vsize = size(dynb.Jo);
Error in dpm>dpm_backward (line 468) dyn.B.lo = dpm_boundary_line_lower(model,par,grd,dis,options);
Error in dpm (line 407) dyn = dpm_backward(model,par,grd,dis,options);
Error in truck_main (line 156) [res dyn] = dpm(@truck,[],grd,prb,options);
Walter Roberson
Walter Roberson le 26 Juin 2015
Your dynb is either one of the arguments passed in or else it is calculated from the arguments. We do not know which. However it is being created, it is not a structure when it is expected to be.

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by