フィルターのクリア

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

1 回表示 (過去 30 日間)
Rajesh
Rajesh 2022 年 7 月 24 日
コメント済み: Rajesh 2022 年 7 月 24 日
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 Center および File ExchangeGraphics Object Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by