How do i write algorithms

조회 수: 7 (최근 30일)
Antwone Goodwyn
Antwone Goodwyn 2019년 4월 29일
댓글: Walter Roberson 2019년 4월 30일
Develop M-file that can do followings
- Ask you starting and final number to add up (e.g., ni=0, nf=300)
- Display the total of the numbers (e.g., sum=0+1+2+....+300)
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 4월 29일
  • disp()
  • for
  • input()
  • plus()

댓글을 달려면 로그인하십시오.

채택된 답변

Raj
Raj 2019년 4월 29일
Many ways of doing this problem. Below is one way:
ni=input('Enter initial value:');
nf=input('Enter final value:');
A=zeros(nf-ni,1);
A(1)=ni;
for i=2:size(A)+1
A(i)=A(i-1)+1;
end
Sum=sum(A)
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 4월 30일
We do not recommend posting complete solutions to homework problems.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by