want to create vector in output

1 回表示 (過去 30 日間)
Ali Asghar
Ali Asghar 2019 年 7 月 25 日
回答済み: Walter Roberson 2019 年 7 月 25 日
Dear
i need help in get the output who solve the numbers by given formula and give output in vector form which have all data.....
x=[ 1 5 10 20 30 45];
n = numel(x); % number of elements in x
i=1;
for zzzz=1:n-1
b=x(i+1);
c=x(i);
wavelengthacceleration=[b-c]
i=i+1;
end
I need OUTPUT like
wavelengthacceleration = [4 5 10 10 15]
The above program show only final value of 15 in workspace.
Thank you

採用された回答

Walter Roberson
Walter Roberson 2019 年 7 月 25 日
wavelengthacceleration = diff(x) ;
With no loops needed

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by