how to put them text lines into loop to reduce the coding line?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
muhammad choudhry
le 19 Oct 2020
Réponse apportée : Walter Roberson
le 19 Oct 2020
plot (x,y(1:10:end,:),'Color',[0.4940, 0.1840, 0.5560],'LineStyle','-','LineWidth',1.5);
hold on
text(1.688,0.038,'ola')
text(1.688,0.028,'ola1')
text(1.688,0.02,'ola2')
text(1.688,0.013,'ola3')
text(1.688,0.0076,'ola4')
text(1.688,0.004,'ola5')
text(1.688,0.0015,'ola6')
text(1.688,0,'ola7')
hold all
0 commentaires
Réponse acceptée
Walter Roberson
le 19 Oct 2020
text(repmat(1.688, 1, 8),[0.038, 0.028, 0.02, 0.13, 0.0076, 0.004, 0.0015, 0], {'ola', 'ola1', 'ola2', 'ol3', 'ol4', 'ola5', 'ola6', 'ola7'})
or
y = [0.038, 0.028, 0.02, 0.13, 0.0076, 0.004, 0.0015, 0];
x = 1.688 * ones(size(y));
str = {'ola', 'ola1', 'ola2', 'ol3', 'ol4', 'ola5', 'ola6', 'ola7'};
text(x, y, str)
0 commentaires
Plus de réponses (2)
KSSV
le 19 Oct 2020
x = rand(9,1) ;
y = rand(9,1) ;
str = strcat(repelem('ola',9,1),num2str((0:8)')) ;
text(x,y,str)
0 commentaires
Ameer Hamza
le 19 Oct 2020
Try this
yv = [0.038 0.028 0.02 0.013 0.0076 0.004 0.0015 0];
hold on
for i = 1:numel(yv)
text(1.688, yv(i), sprintf('ola%d', i));
end
0 commentaires
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!