MATLAB: How to use for loop and ifelse condition with Nx1 matrix.

replace a value in matrix

A:N x 1 matrix.
n = size(A,1)
for i = 1:n % increment 1
if A(i,1) = 5 % Error: The expression is to the left....
A(i,1) = 1 % when A(i,1) = 5 , replace A(i,1) original value to 1.
Error message.
Error: The expression to the left of the equals sign is not a valid target for an assignment.
Do you know how to replace original values in a matrix to a specific value on the basis of comparision between matrix value and a value such as 5?

Best Answer

MATLAB uses == for comparisons, not =