What is an error in the GUI?

1 visualización (últimos 30 días)
Veronika
Veronika el 24 de Feb. de 2015
Comentada: Stephen23 el 2 de Mzo. de 2015
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?
  3 comentarios
Stephen23
Stephen23 el 24 de Feb. de 2015
Editada: Stephen23 el 24 de Feb. de 2015
show_fem is part of this toolbox:
Veronika
Veronika el 24 de Feb. de 2015
show_fem comes from EIDORS http://eidors3d.sourceforge.net/

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 24 de Feb. de 2015
Editada: Stephen23 el 24 de Feb. de 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 comentarios
Veronika
Veronika el 28 de Feb. de 2015
Thank you, I used debugging and I figured out where the error is. It is in size of variables, especially in elem.data. Elem.data aren´t the same. I need to variables img_1, img_2, img_test and img_input had equally large elem_data best 2959x1 double. Do you have any idea how to do it? I attached file with my code.
Stephen23
Stephen23 el 2 de Mzo. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by