Create row with text from loop for a table

I want to create a table with a row like this:
[Bar No.1; Bar No.2 ... Bar No.n]
I tried it with:
%N = 4x6;
capa = zeros(size(N,1),1);
i=1;
while i<= size(N,1)
capa(i) = sprintf('Capa #%d',i);
i=i+1;
end
I tried also with fprintf, but it doesn't work.
My table has other information which I want to add this column as first:

 采纳的回答

you can create table headers with:
a=table();
for i=1:10;
a.(sprintf('bar %g',i))=i;
end

3 个评论

Thank you. I get this message: «To assign to or create a variable in a table, the number of rows must match the height of the table.»
I check the size of the matrix which I work and nothing.
N=4;
a=table();
for i=1:10;
a.(sprintf('bar %g',i))=zeros(N,1);
end
How about adding columns with loops? Can you help me?

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

产品

版本

R2020a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by