如何添加不同长度的向量? [英] How to add vectors with different length?
本文介绍了如何添加不同长度的向量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Matlab或Octave中添加两个具有不同长度的向量.例如
I would like to add two vectors with different lengths in Matlab or Octave. E.g.
aa = [1 2 3 4];
bb = [100 100];
哪个应导致矢量cc包含
Which should result in a vector cc containing
cc = [101 102 3 4]
任何人都可以弄清楚该怎么做吗?
Can anyone figure out how to do this?
更新:这是我最终获得的信号代码,随后我将其转换为灰度图像.
Update: This is the code I ended up with for the signals that I then later convert to grey scale images.
load train;
t = y;
load chirp;
c = y;
tc = c + [t; zeros(length(c) - length(t),1)];
plot(1:length(tc),tc)
非常感谢大家=)
推荐答案
从数学上讲这没有任何意义,但是如果您坚持,可以这样做:
This doesn't make any sense mathematically, but if you insist, you can do this:
cc = aa + [bb zeros(1,2)];
这篇关于如何添加不同长度的向量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文