MATLAB Answers


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

Latest activity Answered by Rik
on 20 Oct 2019
%Program that types out a line with n integers starting with n0
%Author Dmitri
%% set parameters
%% calculate
for n0=5:n
%% Display results


This can be done without a loop, does your assignment require one? Should n and n0 be inputs to the function, or is it fine to leave them hard-coded as you did in your current code?
This needs to be done with a loop and it is fine to leave them hard-coded.

Sign in to comment.

1 Answer

Answer by Rik
on 20 Oct 2019
 Accepted Answer

Since this is a homework assignment, I will leave some blanks for you to fill in.
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
If you need a more explicit hint for the definition of k, feel free to post a comment.


Sign in to comment.