subtract values inside a array
3 views (last 30 days)
Show older comments
Mohamed Musni
on 22 Jan 2018
Commented: Mohamed Musni
on 22 Jan 2018
any help will be great. Thank you
0 Comments
Accepted Answer
More Answers (2)
Birdman
on 22 Jan 2018
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
on 22 Jan 2018
Edited: Mohammed Bahubayl
on 22 Jan 2018
function output =difff(x)
intial=50;
output=[];
for i=1:length(x)
output(end+1)=intial-x(i);
intial=output(end);
end
end
See Also
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!