Matlab filter columns of array based on value in row
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nobutaka Kim
am 7 Feb. 2022
Beantwortet: Arif Hoq
am 7 Feb. 2022
I have a 3 x 3000 array with x, y, z as the rows.
I want a new array from filtering the above if z == 3.
I tried
```
task3_xy = xy_arr(~ismember(xy_arr(3, :), [3]),:);
```
but it's telling me
The logical indices in position 1 contain a true value outside of
the array bounds.
How else can I do this?
0 Kommentare
Akzeptierte Antwort
Arif Hoq
am 7 Feb. 2022
use 'find' function to look up the value which is equal to 3 in 'z'
x=randi(100,3,3000);
y=randi(80,3,3000);
z=randi(50,3,3000)
Idx_New_array=find(z==3) % index value of z whihc is equal to 0
if you want to find the row and column
[row col]=find(z==3)
is that your expectation or you want to replace the index value of z ?
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Logical 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!