如何在MATLAB中将元素追加到数组? [英] How to append an element to an array in MATLAB?

查看:1644
本文介绍了如何在MATLAB中将元素追加到数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将elem附加到数组A的末尾.

I wish to append my elem to the end of an array A.

我该怎么办?

推荐答案

使用以下内容

A = [A elem] % for row array

A = [A; elem] % for col array


另一个更简单的方法是(如@BenVoigt建议)使用end关键字


Another simpler way is (as @BenVoigt suggested) to use end keyword

A(end+1) = elem;

适用于行向量和列向量.

which works for both row and column vectors.

这篇关于如何在MATLAB中将元素追加到数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆