Create vector with predetermined number of certain elements
我有一个问题,我有一组数字,例如; [3 5 9] 以及每个数字的出现次数,例如。 [2 1 5]。现在我想创建一个包含这些数字预先指定次数的向量,因此对于示例,结果将是 [3 3 5 9 9 9 9 9]。在 MATLAB 中是否有一种优雅的方法可以做到这一点,即矢量化?
- 这是另一个stackoverflow.com/q/2382319/97160,可能还有更多问题
repelem 是你想要的函数
1 2 3 4 5
|
a = [3, 5, 9]; b = [2, 1, 5]; c = repelem (a,b )
c =
3 3 5 9 9 9 9 9
|
来源:https://www.codenong.com/36249471/
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8945.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57