将列向量复制为更长的列向量 [英] Duplicating a column vector into a longer column vector

查看:59
本文介绍了将列向量复制为更长的列向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

A = [3;4;5]开始,我想将其复制六次以获得A =[3;3;3;3;3;3;4;4;4;4;4;4;5;5;5;5;5;5].

Starting with A = [3;4;5], I want to duplicate it six times to get A =[3;3;3;3;3;3;4;4;4;4;4;4;5;5;5;5;5;5].

我可以想到一些蛮力的方法,但是正在寻找优化的东西,因为它将多次循环运行.

I can think of some brute force ways to do it, but looking for something optimized since this will be run through a loop many times.

推荐答案

如何使用 kron ?非常适合此目的.

How about using kron? It's very suited for this purpose.

kron(A,ones(6,1))

这篇关于将列向量复制为更长的列向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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