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?
0 个评论
采纳的回答
Adam
2019-1-30
diff(A)
will do this.
3 个评论
Andrei Bobrov
2019-1-30
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!