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 view (last 30 days)
%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 Comments

Sign in to comment.

Accepted Answer

Rik
Rik on 20 Oct 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.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!