Question

I have a GUI menu on Matlab with 4 buttons (menu.fig). Then I have 4 .fig file that I want to open when I click on the buttons. Here it's all ok, when I open a .fig from menu and insert value to do a plot I get this error:

???? Attempt to reference field of non-structure array.

If I try to open 1.fig directly, everything works perfectly.

I read that the problem is with eval(), but I can't solve it.

I changed the variable names on each .fig file

One 1.fig:

function pbutton1_Callback(hObject, eventdata, handles)
A1=get(handles.edtSAmp,'String');
f1=get(handles.edtSFreq, 'String');
fi1=get(handles.edtSFase, 'String');
t1=get(handles.popTipo, 'Value');

A1=str2double(A1);
f1=str2double(f1);
fi=str2double(fi1);

SinalSinusoidal(A1,f1,fi,t1);

I got the error on the that 1st line.

Was it helpful?

Solution

I guess this is something MATLAB GUI not handled well. I know it used to work, but when you tweaking your UI or UI related code a bit and accidentally you modified some area MATLAB told you not to touch, this kind of issue begin to happen.

The workaournd is to start the GUI from M editor by clicking run

I know it works, but originally, when I directly lauch it , it works too. so, this is not the end of it, people are just not getting to the end of it.

OTHER TIPS

The problem is with probably with handles1. It's not a structure array like you expect it to be. In GUI's created with GUIDE, this variable is usually called handles, if you have both handles and handles1 make sure handles1 contains handles to the objects in the figure. If you're using handles1 only, make sure you're initializing it properly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top