How to create an array with the same letter but different number

1 次查看(过去 30 天)
Hi,
How can I create an array or cell, something like Variable = {'X1','X2','X3',...,'X43'}? when i give for example the length = 43.
So when I do my plots, i call put the title as title (variable(i))
Thanks!

采纳的回答

Jan
Jan 2018-10-17
Len = 43;
V = sprintfc('X%d', 1:Len);
Or with modern Matlab versions:
V = compose('X%d', 1:Len);
Then:
title(V{i})

更多回答(1 个)

KSSV
KSSV 2018-10-17
for i = 1:10
plot(rand(1,10))
title(sprintf('X%d',i))
drawnow
pause(0.5)
end

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by