How do I combine these answers into a matrix?

1 次查看(过去 30 天)
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?

采纳的回答

Adam
Adam 2019-1-30
diff(A)
will do this.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by