Integrate Simulink + GUI: Attempt to reference field of non-structure array.

1 vue (au cours des 30 derniers jours)
Matilde P.M. Pato
Matilde P.M. Pato le 21 Mai 2015
Hello
My problem is: I wrote a code in Gui, for a startstop button. Since I run my gui, a Scope window opens with the results. It is all ok. Now, I want to plot the Scope results in a different figure to save it. To do that I use the following:
(...)
figure(1)
plot(ScopeData.time, ScopeData.signals(1,2).values(:,1),ScopeData.time, ScopeData.signals(1,2).values(:,2));
(...)
In fact, a new figure is open with the result. However, an error message appear too
"Attempt to reference field of non-structure array.
Error in METRE>pushbutton_startstop_Callback (line 182) plot(ScopeData.time, ScopeData.signals(1,2).values(:,1),ScopeData.time, ScopeData.signals(1,2).values(:,2));
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in METRE (line 62) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)METRE('pushbutton_startstop_Callback',hObject,eventdata,guidata(hObject))
Error using pause Error while evaluating uicontrol Callback "
Where is the problem? I have my figure with the plot. But I dont want to see this message.
Thanks, Matilde

Réponses (1)

Sebastian Castro
Sebastian Castro le 22 Mai 2015
I would check a few things to narrow down the problem.
First off, do you have access to the ScopeData variable inside that callback function? I'm not 100% sure of this, but that data gets generated in the MATLAB base workspace and may not be accessible inside function workspace. I would, of course, check this on your end.
If you can access that variable, do the commands ScopeData.time and ScopeData.signals(1,2).values(:,1) execute without errors? Is there a syntax error, or does MATLAB simply not like all that indexing in one line?
I'd recommend putting a breakpoint in that callback function and testing things out incrementally to see what's up.
- Sebastian
  1 commentaire
Matilde P.M. Pato
Matilde P.M. Pato le 22 Mai 2015
Hello Sebastian
Thanks for your answer. In fact I can acess the data from ScopeData, and for this I have a figure with the results. However, I do not understand the reason for MatLab display the error message.
I' ve done the breakpoint.
Matilde

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interactive Control and Callbacks 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