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

1 次查看(过去 30 天)
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]

采纳的回答

Jan
Jan 2022-7-24
编辑:Jan 2022-7-24
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Identification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by