How to get from a array to a vector

1 回表示 (過去 30 日間)
Mark Loui
Mark Loui 2021 年 3 月 18 日
回答済み: Jan 2021 年 3 月 19 日
Hi there i have a question
n=10;
x=rand(n,1)
for i=1:n-1
h(i)=x(i+1)-x(i);
iter_h=iter_h+1;
end
I get the ouput which is in array is this right? If so how can i change to a vector?

採用された回答

Jan
Jan 2021 年 3 月 19 日
Vectors are arrays.
Your code does not use iter_h anywhere. It can be simplified to:
n = 10;
x = rand(n, 1);
h = diff(x);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpatial Search についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by