Mulitpling a scalar to specfic numbers in a vector
조회 수: 4 (최근 30일)
이전 댓글 표시
I need to multiply random numbers in a vector by a different scalar depending on what numbers are in the vector. For example, [1 3 5 10 15 17 20 25 30]; I would have to multiply the 1,3 and 5 by 2, and the 10,15,17 by 5, but the 20,25, and 30 would be multiplied by 10. So the vector would look like [2 6 10 50 75 85 200 250 300].
댓글 수: 0
채택된 답변
Matt J
2022년 9월 7일
편집: Matt J
2022년 9월 7일
One way:
[1 3 5 10 15 17 20 25 30].*repelem([2,5,10],3)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Computer Vision Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!