0

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.

Fabio Cardoso
  • 1,181
  • 1
  • 14
  • 37

2 Answers2

2

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.

zinking
  • 5,561
  • 5
  • 49
  • 81
0

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.

Molly
  • 13,240
  • 4
  • 44
  • 45
  • I changed it to try, with handles it doesn't work too.. I'll correct that on the question. – Fabio Cardoso Apr 09 '13 at 00:07
  • Did you change it everywhere in your code? Was this GUI made with GUIDE? – Molly Apr 09 '13 at 00:10
  • I only changed it when I got that error, then I undo the changes. Yes it's made with GUIDE. – Fabio Cardoso Apr 09 '13 at 00:11
  • If you're getting that error on the first line, handles is not a structure. Maybe it's overwritten somewhere. Are you using guidata with handles1? – Molly Apr 09 '13 at 00:27
  • Probably not. Hard to tell without seeing everything. guidata can overwrite your handles structure if used improperly. – Molly Apr 10 '13 at 15:32