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!