how to let elements in each column of a matrix divided by the first element in each column
1 回表示 (過去 30 日間)
古いコメントを表示
is there a simple way to let all the elements in a column of a matrix divided by the first element of each column, without using for loop?
0 件のコメント
回答 (1 件)
dpb
2018 年 8 月 4 日
編集済み: dpb
2018 年 8 月 4 日
x=x./x(1,:);
uses recent automagic(*) singleton expansion, if you have earlier release that errors on size mismatch then use bsxfun
x=bsxfun(@rdivide,x,x(1,:));
(*) I don't recall just when was introduced around R2015 or so...R2014b is earliest presently installed here --
>> x./x(1,:)
Error using ./
Matrix dimensions must agree.
>>
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!