How do I combine these answers into a matrix?
1 view (last 30 days)
Show older comments
Here is the code I have.
A=[1;13;15;20;23;27];
for k=2:6;
[index_diff]=A(k,1)-A(k-1,1)
end
I would like to put the answers (12,2,5,3,4) into a 5 by 1 matrix. How do I do this?
0 Comments
Accepted Answer
Adam
on 30 Jan 2019
diff(A)
will do this.
3 Comments
Andrei Bobrov
on 30 Jan 2019
A=[1;13;15;20;23;27];
n = numel(A)-1;
index_diff = zeros(n,1);
for k=1:n;
index_diff(k) = A(k+1)-A(k);
end
More Answers (0)
See Also
Categories
Find more on Logical 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!