필터 지우기
필터 지우기

Error using < Matrix dimensions must agree.

조회 수: 2 (최근 30일)
Leela Sai Krishna
Leela Sai Krishna 2019년 3월 19일
답변: Star Strider 2019년 3월 19일
a=randi(100,1,10);
b=randi(100,1,10);
c=randi(100,1,10);
A=[a;b;c]
A_max=max(A);
A(A<0.15*A_max)=nan
it gives following error
Error using <
Matrix dimensions must agree.
How to rectify it...

채택된 답변

Star Strider
Star Strider 2019년 3월 19일
You apparently have R2016a or earlier, so you do not have ‘automatic implicit expansion’ that was part of R2016b and later versions.
Try this:
idx = bsxfun(@lt, A, 0.15*A_max);
A(idx) = NaN;
You can combine them in one line if you like. This code illustrates the approach.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by