hi
I have following array. I want to add NaN at diagonal position of each cell. LIKE x{1,1}, NaN will be added at x{1,1}(1,1).. for x{1,2}, NaN will be added at x{1,2}(1,2) & so on
x= {[0.79,0.31,0.24,0.71,0.1],[0.79,0.12,0.71,0.62,0.24]}

 採用された回答

Birdman
Birdman 2018 年 1 月 11 日
編集済み: Birdman 2018 年 1 月 11 日

0 投票

for i=1:size(x,2)
x{1,i}(i)=NaN;
end
Type
x{1,:}
and see the result.

3 件のコメント

Tha saliem
Tha saliem 2018 年 1 月 11 日
Thank You. But it replaces the first value with NaN. I want to keep other values as it is.
x= {[NaN,0.79,0.31,0.24,0.71,0.1],[0.79,NaN, 0.12,0.71,0.62,0.24]}
Birdman
Birdman 2018 年 1 月 11 日
編集済み: Birdman 2018 年 1 月 11 日
Then,
x{1,1}(2:end+1)=x{1,1}(1:end);
x{1,2}(2:end+1)=x{1,2}(1:end);
for i=1:size(x,2)
x{1,i}(i)=NaN;
end
Tha saliem
Tha saliem 2018 年 1 月 11 日
Thanks Alot

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperating on Diagonal Matrices についてさらに検索

タグ

質問済み:

2018 年 1 月 11 日

コメント済み:

2018 年 1 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by