Filter löschen
Filter löschen

Changing elements of row after certain element of m*n matrix

1 Ansicht (letzte 30 Tage)
Rajesh
Rajesh am 24 Jul. 2022
Kommentiert: Rajesh am 24 Jul. 2022
Hi,
I have a m*n matrix where some of rows are like these for exmaple
x=[-1,-0.65,-0.45,0,0.3,0.8,1,0.4,0.2,-0.1;
-1,-0.65,-0.45,0,0.3,0.8,0.9,1,0.2,-0.1]
I know the idx=[7,8] after which the elements become 0.
Now I need to make new row as follows using idx
x1=[-1,-0.65,-0.45,0,0.3,0.8,1,0,0,0;
-1,-0.65,-0.45,0,0.3,0.8,0.9,1,0,0]

Akzeptierte Antwort

Jan
Jan am 24 Jul. 2022
Bearbeitet: Jan am 24 Jul. 2022
x = [-1, -0.65, -0.45, 0, 0.3, 0.8, 1, 0.4, 0.2, -0.1;
-1, -0.65, -0.45, 0, 0.3, 0.8, 0.9, 1, 0.2, -0.1];
idx = [7, 8];
m = (1:size(x, 2)) > idx(:);
x(m) = 0
x = 2×10
-1 -0.65 -0.45 0 0.3 0.8 1 0 0 0 -1 -0.65 -0.45 0 0.3 0.8 0.9 1 0 0

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Identification 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!

Translated by