poster
2019-12-14, 20:13
在Haskell中 (http://en.wikipedia.org/wiki/Haskell_%28programming_language%29) ,如果我想获取仅包含数字5的10元素列表,则可以执行以下操作:
take 10 $ repeat 5 输出:
[5,5,5,5,5,5,5,5,5,5] Matlab中有类似的东西吗?
回答:
将重复的值分配给数组很容易:
x(1:10) = 5; 如果要在语句中内联生成元素数组,请尝试以下操作:
ones(1,10) * 5 或搭配repmat (http://ch.mathworks.com/help/matlab/ref/repmat.html;jsessionid=f1464648af2c6b017506485689f6)
repmat(5, 1, 10)
更多&回答... (https://stackoverflow.com/questions/4918763)
take 10 $ repeat 5 输出:
[5,5,5,5,5,5,5,5,5,5] Matlab中有类似的东西吗?
回答:
将重复的值分配给数组很容易:
x(1:10) = 5; 如果要在语句中内联生成元素数组,请尝试以下操作:
ones(1,10) * 5 或搭配repmat (http://ch.mathworks.com/help/matlab/ref/repmat.html;jsessionid=f1464648af2c6b017506485689f6)
repmat(5, 1, 10)
更多&回答... (https://stackoverflow.com/questions/4918763)