Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 Matlab 中将变量推入向量中?
像这样的东西:
A = [5 2 3]; push(A, 7); % A = [5 2 3 7]
谢谢。
我找到了答案。
用这个:
A = [A, 7];
或这个:
A(end + 1) = 7;
如果你想垂直堆叠它,你可以使用
A = [A; 7]
但是要执行此操作, A 应该与下一个参数具有相同的尺寸。例如,如果
A=[1,2 3,4]
您可以在 A 中堆叠长度为 2 的向量
A = [A;5,6]