How the replace values in one matrix by comparision with another?
5 views (last 30 days)
Show older comments
Hi Matlab users,
My problem is this: I have 2 matrix of the same size let's say A=(238;132;70) and B=(238;132;70). They have different contents but matrix A has the number -99 a lot of times in it (which represents land) and matrix B has also the number -99 in it, but fewer values. How can I make so that matrix B will keep it's own values, except for the points where matrix A has -99 value, case in which it will write -99?
Best regards,
Robert.
0 Comments
Accepted Answer
Image Analyst
on 26 May 2012
% Get a logical map of where -99 occurs in A
locations99inA = (A == -99);
% Assign ONLY THOSE locations in B to be 99
% leaving all other elements of B unchanged.
B(locations99inA) = -99;
More Answers (0)
See Also
Categories
Find more on Annotations 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!