replace elements of a matrix with another matrix
Mostrar comentarios más antiguos
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 comentarios
KALYAN ACHARJYA
el 7 de Nov. de 2019
Editada: KALYAN ACHARJYA
el 7 de Nov. de 2019
I have an question, suppose you have matrix A=[4 5 7;8 9 10]; now replace 7 by matrix a as given in your question? What would be the result in this case?
geetha senthil
el 7 de Nov. de 2019
KALYAN ACHARJYA
el 7 de Nov. de 2019
Editada: KALYAN ACHARJYA
el 7 de Nov. de 2019
You didnot provide the answer of my question, what would be the asnwer as per your logic??
Result=??
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!