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

1 visualización (últimos 30 días)
Rajesh
Rajesh el 24 de Jul. de 2022
Comentada: Rajesh el 24 de Jul. de 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]

Respuesta aceptada

Jan
Jan el 24 de Jul. de 2022
Editada: Jan el 24 de Jul. de 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

Más respuestas (0)

Categorías

Más información sobre Graphics Object Identification en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by