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 Kommentar

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)"?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

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)

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by