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 (최근 30일)
이전 댓글 표시
%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
채택된 답변
Rik
2019년 10월 20일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!