how to put them text lines into loop to reduce the coding line?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
muhammad choudhry
am 19 Okt. 2020
Beantwortet: Walter Roberson
am 19 Okt. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 19 Okt. 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 Kommentare
Weitere Antworten (2)
KSSV
am 19 Okt. 2020
x = rand(9,1) ;
y = rand(9,1) ;
str = strcat(repelem('ola',9,1),num2str((0:8)')) ;
text(x,y,str)
0 Kommentare
Ameer Hamza
am 19 Okt. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!