Octave/Matlab:扩展向量使其重复? [英] Octave / Matlab: Extend a vector making it repeat itself?

查看:23
本文介绍了Octave/Matlab:扩展向量使其重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过重复自身来扩展向量?

Is there a way to extend a vector by making it repeat itself?

>v = [1 2];
>v10 = v x 5; %x represents some function. Something like "1 2" x 5 in perl

那么 v10 将是:

>v10
     1 2 1 2 1 2 1 2 1 2

这应该适用于一般情况,而不仅仅是 [1 2]

This should work for the general case, not just for [1 2]

推荐答案

您正在寻找的功能是 repmat().

The function you're looking for is repmat().

v10 = repmat(v, 1, 5)

这篇关于Octave/Matlab:扩展向量使其重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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