Vector with numerator 1 unit less than denominator

조회 수: 1 (최근 30일)
Deana Sadrieva
Deana Sadrieva 2020년 2월 2일
댓글: Stephen23 2020년 2월 3일
How can I make a vector with these values?
0, 1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10

답변 (1개)

Raj
Raj 2020년 2월 3일
format rat
A=input('Enter number of elements:') % Enter 10 for this example
for ii=1:A
Out_Vector(ii)= (ii-1)/ii;
end
Out_Vector
  댓글 수: 3
Raj
Raj 2020년 2월 3일
Sorry. Didn't realize it was a homework problem.
Stephen23
Stephen23 2020년 2월 3일
This is MATLAB, so there is no need to use a loop. This approach is simpler and more efficient:

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by