Integrate Simulink + GUI: Attempt to reference field of non-structure array.
Ältere Kommentare anzeigen
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
Antworten (1)
Sebastian Castro
am 22 Mai 2015
0 Stimmen
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
Kategorien
Mehr zu Simulink Environment Customization 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!