Adding sprintf values using a loop

12 次查看(过去 30 天)
Dear group,
I'm trying to plot multiple subplots and adding names using loop.I tried to add a single name it works in a loop but adding multiple sprintf is snot changing the varibles ? What's the error in this?
Thanks in advance
figure
for k = 1 : 12
for a = 1:12
subplot(3,4,k);
Spec = ' A%d', 'S%d ';
caption = sprintf(Spec,k, a);
title(caption, 'FontSize', 12, 'HorizontalAlignment', 'center');
end
end

采纳的回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2022-1-12
Spec =['A%d ','S%d'];
  3 个评论
Stephen23
Stephen23 2022-1-12
['A%d ','S%d']
is just a complex way of writing
'A%d S%d'
KALYAN ACHARJYA
KALYAN ACHARJYA 2022-1-12
编辑:KALYAN ACHARJYA 2022-1-12
yes sir Thanks @Stephen
@Ramesh Bala Are you looking for the following
Spec ='A%d S%d';
caption=sprintf(Spec,k,k)
if not, hope you noted about the nested loops iterations.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by