How the replace values in one matrix by comparision with another?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Image Analyst
2012 年 5 月 26 日
% 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;
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!