I'm trying to write a program that types out a line with n integers starting with n0 , separated by commas and spaces. It needs to use a forloop and should turn out like this n=10 n0=5 --> 5, 6, 7, 8, 9, 10, 11, 12, 13, 14. This is what I have so far
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Custode Dmitri Francesco
am 20 Okt. 2019
Beantwortet: Rik
am 20 Okt. 2019
%Countem
%Program that types out a line with n integers starting with n0
%Author Dmitri
clear;clc
%% set parameters
n=10
%% calculate
for n0=5:n
f(n0)=n0
end
%% Display results
3 Kommentare
Akzeptierte Antwort
Rik
am 20 Okt. 2019
Since this is a homework assignment, I will leave some blanks for you to fill in.
n=10;n0=5;
clc%clear command window
for k=n0+(___ vector with n elements, starting at 1 ___)-1
fprintf(_____,k);%look up fprintf in the documentation to see how it works
end
If you need a more explicit hint for the definition of k, feel free to post a comment.
0 Kommentare
Weitere Antworten (0)
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!