a为1:47的数组,现需要将数组中每个元素复制10次,依次排列成1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2······,代码如下: a = 1:47; fun = @(x) repmat(x,1,10); arrayfun(fun,a); 出现错误,Error using arrayfun Non-scalar in Uniform output, at index 1, output 1. Set 'UniformOutput' to false.求各位前辈看看怎么回事。 |
最佳答案
4 条回复
winner245 发表于 2015-10-30 09:59 多谢提醒,其实还是自己对arrayfun函数用法不熟练,代码已改 a = 1:47; fun = @(x) repmat(x,1,10); b = zeros(1,length(a)*10); b = arrayfun(fun,a,'UniformOutput',false); b = cell2mat(b); |
yueye1104 发表于 2015-10-30 10:15 其实要实现这个功能只需一条命令: repelem(1:47,10) |
Powered by Discuz! X3.4
© 2001-2022