replace elements of a matrix with another matrix
7 ビュー (過去 30 日間)
古いコメントを表示
geetha senthil
2019 年 11 月 7 日
コメント済み: Patrick Rousseau
2021 年 9 月 2 日
Hai
I need to replace the element of matrix 'A' by matrix 'a' if the value of the element is greater than 50 and by matrix 'b' if the value is less than 50,so that i will get a 32x32 matrix.I have given the code below.Help me please.thanks
A = randi (100 , 16 , 16) ;
a=[5 5;5 5];
b=[20 20;20 20 ];
for i = 1:16
for j = 1:16
if A (i , j ) > 50
R( i,j ) = [a] ;
else
R( i,j ) = [b] ;
end
end
end
3 件のコメント
KALYAN ACHARJYA
2019 年 11 月 7 日
編集済み: KALYAN ACHARJYA
2019 年 11 月 7 日
You didnot provide the answer of my question, what would be the asnwer as per your logic??
Result=??
採用された回答
JESUS DAVID ARIZA ROYETH
2019 年 11 月 7 日
solution :
A = randi (100 , 16 , 16) ;
s=A>50;
a=[5 5;5 5];
b=[20 20;20 20 ];
R=num2cell(A);
R(s)={a};
R(not(s))={b};
R=cell2mat(R)
2 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!