Selecting from a range of values from a column matrix
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Austin Ukpebor
am 7 Okt. 2021
Kommentiert: Austin Ukpebor
am 7 Okt. 2021
I have a column matrix (398404 x1). I want any values less than 42 between rows 290360 and 380876 to be 5 while values outside those rows remain the same. Please I need help. Thank you.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Okt. 2021
r1 = 290360; r2 = 380876;
extract = YourMatrix(r1:r2);
extract(extract < 42) = 5;
YourMatrix(r1:r2) = extract;
or...
r1 = 290360; r2 = 380876;
rowidx = (1:numel(YourMatrix)).';
mask = rowidx >= r1 & rowidx <= r2 & YourMatrix < 42;
YourMatrix(mask) = 5;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Least Squares 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!