how can i write a code that show replacing the values in the combined matrix (m1m2) that are greater than n1 with c1, and those that are less than or equal to n1 with c2?

thank you very much

1 Comment

The question is not clear. A small example would reduce the need to guess, what you mean. E.g. what is "a combine matrix (m1m2)"?

Sign in to comment.

 Accepted Answer

Perhaps you mean something like this:
X = rand(3,4); % Test data
match = X > n1;
X(match) = c1;
X(~match) = c2;
Another method:
pool = [c1, c2];
Y = pool((X > n1) + 1)

More Answers (0)

Products

Asked:

on 9 Oct 2013

Commented:

on 9 Oct 2013

Community Treasure Hunt

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

Start Hunting!