フィルターのクリア

What is the difference between linspace and the colon operator in this code?

2 ビュー (過去 30 日間)
Timo Kuchheuser
Timo Kuchheuser 2017 年 11 月 12 日
コメント済み: Timo Kuchheuser 2017 年 11 月 12 日
Hi! What is the difference between the linspace function and the colon operator in this code?
v1 = (0:1/200:1);
v2 = linspace(0,1,200);
>> v1==v2
Matrix dimensions must agree.
Why is there one element more in v1 than in v2?
Thank you very much Timo

採用された回答

Matt J
Matt J 2017 年 11 月 12 日
編集済み: Matt J 2017 年 11 月 12 日
Because the interval between the elements of v2 is not 1/200. It's 1/199.
>> isequal(v2(2)-v2(1),1/199)
ans =
logical
1
That is the separation needed to get 200 equally spaced points.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by