Effacer les filtres
Effacer les filtres

Put struct in a uitable gui

1 vue (au cours des 30 derniers jours)
Abel Romero
Abel Romero le 16 Déc 2017
Réponse apportée : Jan le 18 Déc 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 commentaire
Jan
Jan le 18 Déc 2017
"handles.resn=(handles.resn);" is meaningless. Omit it.
What does not work with the shown code?

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 18 Déc 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.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by