フィルターのクリア

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 Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by