can text next to input be different in each loop?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abdelrhman Mahmoud
am 19 Feb. 2019
Bearbeitet: Luna
am 19 Feb. 2019
for i =1 : 5
fprintf('Enter Height %d', i)
x=input('');
end
is there a neater way to write this code ?
i.e : use one function only
0 Kommentare
Akzeptierte Antwort
Luna
am 19 Feb. 2019
Bearbeitet: Luna
am 19 Feb. 2019
Hi,
Input can get prompt string as an input already. You can use both:
promptString = 'Enter Height';
for i = 1:5
x=input([promptString,' ', num2str(i),': ']);
end
%% OR %%
promptString = 'Enter Height';
for i = 1:5
x=input([promptString,' ', sprintf('%d',i),': ']);
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assembly 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!