フィルターのクリア

I want to fill my table in a loop, the variable names do not change along

2 ビュー (過去 30 日間)
Lotte van Dijk
Lotte van Dijk 2023 年 7 月 20 日
回答済み: VBBV 2023 年 7 月 20 日
Dear,
I want to fill my table in a loop since i do not know how long the table is going to be. The only thing that does not change along is the variable names. Does anyone know how i can fix this? This is my code and i inserted an image of the result i get.
k=1;
if one==1
for p=1:length(change)
Q_table(p,1)=nanmean(Q_plot(p,:));
end
C = cell(1,length(change));
changen = (strcat(string(cell2mat(x(index(1,1),1)))+ ' ',string(cell2mat(x(index(1,1),2))) + ' ', string(cell2mat(x(index(1,1),3)))));
for u=1:length(change)
C{1,k}=convertStringsToChars(changen(1,k));
T(1,k) = table(num2cell(change(1,k)),...
'VariableNames',{convertStringsToChars(changen(1,k)),},...
'RowNames',{'Average flow rate [nL/s]'})
k=k+1;
end
fig = figure('Position',[400 300 900 400]);
% set(cgf,'Name','Average flow rate [nL/s]')
% set(gcf,'Name','Average flow rate [nL/s]','NumberTitle','off') % To keep only your title.
uitable(fig,'Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'RowName',T.Properties.RowNames,'Units', 'Normalized', 'Position',[0.1, 0.2, 6, 0.7]);
titleText = uicontrol(fig, 'Style', 'text', 'String', 'Average flow rate [nL/s]', 'FontSize', 12, 'FontWeight', 'bold', 'Units', 'normalized', 'Position', [0.1, 0.9, 0.8, 0.05]);
end

回答 (2 件)

Image Analyst
Image Analyst 2023 年 7 月 20 日
I would build your table (fill it with numbers and strings) first, and then after that loop set the variable names for the columns:
T.Properties.VariableNames = {'Var1', 'Measurement2', 'Metric3'}; % or whatever the column names should be.

VBBV
VBBV 2023 年 7 月 20 日
for u=1:length(change)

Replace the for loop to below

for u=1:length(changen)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by