Adding sprintf values using a loop
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ramesh Bala
le 12 Jan 2022
Modifié(e) : KALYAN ACHARJYA
le 12 Jan 2022
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
0 commentaires
Réponse acceptée
KALYAN ACHARJYA
le 12 Jan 2022
Spec =['A%d ','S%d'];
3 commentaires
Stephen23
le 12 Jan 2022
['A%d ','S%d']
is just a complex way of writing
'A%d S%d'
KALYAN ACHARJYA
le 12 Jan 2022
Modifié(e) : KALYAN ACHARJYA
le 12 Jan 2022
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!