Adding sprintf values using a loop

조회 수: 5 (최근 30일)
Ramesh Bala
Ramesh Bala 2022년 1월 12일
편집: KALYAN ACHARJYA 2022년 1월 12일
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