Vector with numerator 1 unit less than denominator

2 ビュー (過去 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 件のコメント
Walter Roberson
Walter Roberson 2020 年 2 月 2 日
Hint:
A ./ B
where A and B are vectors.

サインインしてコメントする。

回答 (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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by