subtract values inside a array
1 回表示 (過去 30 日間)
古いコメントを表示
any help will be great. Thank you
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169315/image.jpeg)
0 件のコメント
採用された回答
その他の回答 (2 件)
Birdman
2018 年 1 月 22 日
Not the most efficient, but a solution:
init=50;
a=[init 12 2 6 8 6 2 12]
for i=1:numel(a)-1
val=a(1)-a(2);
b(i)=val;
a(1)=[];
a(1)=val;
end
disp(b)
Mohammed Bahubayl
2018 年 1 月 22 日
編集済み: Mohammed Bahubayl
2018 年 1 月 22 日
function output =difff(x)
intial=50;
output=[];
for i=1:length(x)
output(end+1)=intial-x(i);
intial=output(end);
end
end
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!