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 visualización (últimos 30 días)
%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 comentarios

Iniciar sesión para comentar.

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by