フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I write all values of for loop to uitable without overwriting , as following

1 回表示 (過去 30 日間)
Hikmet Osman
Hikmet Osman 2020 年 8 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Tmin=str2double(get(handles.edit43,'String'));
Tmax=str2double(get(handles.edit44,'String'));
for T=Tmin:1:Tmax
Y=(T+0.511)/0.511;
B=sqrt(1-(1/Y^.2));
N=get(handles.popupmenu1,'value');
Z=get(handles.popupmenu1,'value');
D=(5.09978e-29)*N*Z/B.^2;
I=get(handles.popupmenu1,'value');
G=(B.^2)*(Y.^2)*1.022/I;
SP_ion=D*(log(G)-(B.^2));
SP1_ion=SP_ion*10^-6;
p=get(handles.popupmenu1,'value');
SP2_ion=(SP_ion/p)*10^-2;
SP_rad=Z*T*SP_ion/750;
SP1_rad=SP_rad*10^-6;
SP2_rad=(SP_rad/p)*10^-2;
C1=[T;SP_ion;SP1_ion;SP2_ion;SP_rad;SP1_rad;SP2_rad];
L=num2cell(C1');
end
headers1 = {'E(MeV)','SP_ion(MeV/m)','SP_ion(MeV/cm)','SP_ion(MeV*cm^2/g)','SP_rad(MeV/m)','SP_rad(MeV/cm)','SP_rad(MeV*cm^2/g)'};
colFormat1 = {'short','short'};
f1 = figure('Name','SP');
t = uitable('Parent',f1,'Data',L,'ColumnName',headers1,'ColumnFormat',colFormat1,'Units', 'Normalized', 'Position',[0, 0, 1, 1]);
  1 件のコメント
Mario Malic
Mario Malic 2020 年 8 月 25 日
編集済み: Mario Malic 2020 年 8 月 25 日
You overwrite it in your code. Make your variables vectors
ii = 1;
for T=Tmin:1:Tmax
Y(ii,1) =(T+0.511)/0.511; % I see that you're working with rows so,
% you can use this indexing or use Y(ii) and
% transpose it later as you did before
% Index the rest of variables where appropriate
ii = ii+1;
end
If you use row indexing then set the line
C1=[T SP_ion SP1_ion SP2_ion SP_rad SP1_rad SP2_rad];

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by