how to put them text lines into loop to reduce the coding line?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
muhammad choudhry
il 19 Ott 2020
Risposto: Walter Roberson
il 19 Ott 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 Commenti
Risposta accettata
Walter Roberson
il 19 Ott 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 Commenti
Più risposte (2)
KSSV
il 19 Ott 2020
x = rand(9,1) ;
y = rand(9,1) ;
str = strcat(repelem('ola',9,1),num2str((0:8)')) ;
text(x,y,str)
0 Commenti
Ameer Hamza
il 19 Ott 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 Commenti
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!