Filter löschen
Filter löschen

Put struct in a uitable gui

1 Ansicht (letzte 30 Tage)
Abel Romero
Abel Romero am 16 Dez. 2017
Beantwortet: Jan am 18 Dez. 2017
Hello everybody, I have a problem with the uitable in matlab. I create an uitable with 3 columns: Material(string) NL(logical) Number of discretizations(numeric). I want to insert the 2 first fields when i load a file.mat and the third without information because i want to insert the number of discretizations to save it. Can you help me please?
function select_resonator_Callback(hObject, eventdata, handles)
countelement=0;
%load .mat in a resn variable
[nombre, direc] = uigetfile('*.mat','Resonador');
if nombre ==0
return
end
handles.resn= load (fullfile(direc,nombre));
handles.resn=(handles.resn);
%show topE Material and NL in uitable
handles.datos_topE=get(handles.uitable_topE, 'Data');
if isempty(handles.datos_topE)
handles.datos_topE(:,1)=cellstr(handles.resn.stack.TopE.Material);
handles.datos_topE(:,2)=handles.resn.stack.TopE.NL;
handles.datos_topE(:,3)=0;
else
handles.datos_topE(end+1,1)=cellstr(handles.resn.stack.TopE.Material);
handles.datos_tope(end,2)=handles.resn.stack.TopE.NL;
handles.datos_topE(end,3)=0;
end
set(handles.uitable_topE,'Data',handles.datos_topE);
  1 Kommentar
Jan
Jan am 18 Dez. 2017
"handles.resn=(handles.resn);" is meaningless. Omit it.
What does not work with the shown code?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 18 Dez. 2017
If handles.datos_topE is a cell, this line should cause an error:
handles.datos_topE(:,3) = 0;
Try:
handles.datos_topE(:,3) = {0};
I cannot guess, what handles.resn.stack.TopE.NL is. If it is not a cell with a matching size, this assignment will fail also:
handles.datos_topE(:,2)=handles.resn.stack.TopE.NL;
Then please post the error messages and explain the types of the inputs.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by