Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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]

Risposta accettata

Jan
Jan il 24 Lug 2022
Modificato: Jan il 24 Lug 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

Più risposte (0)

Categorie

Scopri di più su Graphics Object Identification in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by