How to use for loop and ifelse condition with Nx1 matrix.
Show older comments
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?
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!