Error using < Matrix dimensions must agree.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leela Sai Krishna
am 19 Mär. 2019
Beantwortet: Star Strider
am 19 Mär. 2019
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...
0 Kommentare
Akzeptierte Antwort
Star Strider
am 19 Mär. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!