Mulitply diffrent numbers in a vector by a corrsponding number.
1 回表示 (過去 30 日間)
古いコメントを表示
I have to multiply a specific number in a vector by different scalars. For example, in the vector: [1 6 8 10 14 20 25] 1,2,8 and 10 would be multiplied by 10, while 14, 20, and 25 would be multiplied by different scalars.
1 件のコメント
Walter Roberson
2022 年 9 月 7 日
Are they to be multiplied based upon value, or based upon position?
If it is based upon value, then are the boundaries based upon range, or are they scattered around?
回答 (2 件)
David Hill
2022 年 9 月 7 日
v=[1 6 8 10 14 20 25];
v(ismember(v,[1 2 8 10]))=10*v(ismember(v,[1 2 8 10]));%similarly for others
0 件のコメント
Walter Roberson
2022 年 9 月 7 日
V = [1 6 8 10 14 20 25]
mask = V <= 10;
V(mask) = V(mask) * 10;
V(~mask) = V(~mask) * 100;
V
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!