Put struct in a uitable gui

1 次查看(过去 30 天)
Abel Romero
Abel Romero 2017-12-16
回答: Jan 2017-12-18
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 个评论
Jan
Jan 2017-12-18
"handles.resn=(handles.resn);" is meaningless. Omit it.
What does not work with the shown code?

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2017-12-18
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.

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by