I have 3x7 matrix. I want to replace any number by 10 (which is greater than 4). I write this code but its not working. Can any body help me ?
A=[1,2,5,2,3,4,2; 4,2,1,5,3,2,3; 1,4,2,3,2,2,1];
% 1 2 5 2 3 4 2
% 4 2 1 5 3 2 3
% 1 4 2 3 2 2 1
for k=1:1:3
if A(k,4)>4
A(k,4)==10
end
end
expected result:
% 1 2 5 2 3 4 2
% 4 2 1 10 3 2 3
% 1 4 2 3 2 2 1

1 comentario

A(k,4)==10
That is a comparison, not an assignment. Assignment uses =

Iniciar sesión para comentar.

 Respuesta aceptada

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2017a

Etiquetas

Preguntada:

el 16 de En. de 2019

Comentada:

el 16 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by