Azzera filtri
Azzera filtri

Put struct in a uitable gui

1 visualizzazione (ultimi 30 giorni)
Abel Romero
Abel Romero il 16 Dic 2017
Risposto: Jan il 18 Dic 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 Commento
Jan
Jan il 18 Dic 2017
"handles.resn=(handles.resn);" is meaningless. Omit it.
What does not work with the shown code?

Accedi per commentare.

Risposte (1)

Jan
Jan il 18 Dic 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.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by