What is an error in the GUI?
1 view (last 30 days)
Show older comments
Dear all
I have this part of code in GUI:
function pushbutton3_Callback(hObject, eventdata, handles)
load ('testovaci_modely3')
disp('Testovací modely byly načteny.')
load ('netrb')
disp('Neuronová síť byla načtena.')
prompt = {'Napište číslo testovacího modelu:'};
dlg_title = 'Vytvoření vlastního testovacího modelu';
num_lines = 1;
z = 2;
x = inputdlg('Napište číslo testovacího modelu:','Vytvoření vlastního testovacího modelu', [1 100]);
if z>=2
disp('Zadali jste správné číslo.')
P = m{1,z};
Y = sim(net,P);
imdl = mk_common_model('d2d1c',16);
img_1 = mk_image(imdl);
img_input = img_1;
img_2.elem_data = Y;
img_test=img_1;
img_test.elem_data=P;
figure
show_fem(img_test)
figure
show_fem(img_2)
else
disp('Zadali jste špatné číslo.')
end
The first figure(img_test) is imaged, but the second isn´t. And Comand Window reports this:
Reference to non-existent field 'type'.
Error in show_fem>proc_params (line 133) if strcmp( mdl(1).type , 'image' )
Error in show_fem (line 37) [img,mdl,opts] = proc_params( mdl, options );
Error in GUI>pushbutton3_Callback (line 142) show_fem(img_2)
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in GUI (line 43) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)GUI('pushbutton3_Callback',hObject,eventdata,guidata(hObject))
Error using drawnow Error while evaluating uicontrol Callback
Does anybody know what's wrong?
Accepted Answer
Stephen23
on 24 Feb 2015
Edited: Stephen23
on 24 Feb 2015
You call show_fem twice. Interestingly the error happens on the second call, so the first call must be fine.
A practical solution is to try and figure out why these two calls are different. Use the debugging tools to look at the variables img_test and img_2 just before they are used as arguments to show_fem. See how they are different, and maybe change whatever it is that is different to make the second call work properly.
Another solution is to review the documentation for show_fem and double-check that your input variables fulfill all of the stated prerequisites.
If you want to know why this happens, then we can read this directly from the error message:
Error in GUI>pushbutton3_Callback (line 142) show_fem(img_2)
means you call show_fem with variable img_2. Internally show_fem then calls another function called proc_params, which outputs a variable named mdl:
[img,mdl,opts] = proc_params( mdl, options )
mdl is (presumably) a structure, but the expected field type is missing, thus:
if strcmp( mdl(1).type , 'image' )
gives the error message
Reference to non-existent field 'type'.
To know why type is missing would require digging through all of that code. If you open proc_params and search for mdl.type (and similar) you might find some references to this, and get an idea of why it is not being defined.
2 Comments
Stephen23
on 2 Mar 2015
Sorry but I don't use EIDORS, so I can't run your code. If you need to resize some data, then there are multiple ways to do this: including interpolation, subsampling, spline fitting, and much more. What you use depends on you and your requirements.
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!