MATLAB Answers

want to create vector in output

1 view (last 30 days)
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

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 25 Jul 2019
wavelengthacceleration = diff(x) ;
With no loops needed

  0 Comments

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2018b