フィルターのクリア

how to define if or for for the following question

2 ビュー (過去 30 日間)
Abo
Abo 2015 年 11 月 13 日
回答済み: James Tursa 2015 年 11 月 13 日
I have matrix x=[1 2 4 5] and matrix y= [3 4 2 4], i wanna find if x(i,j)-y(i,j)<0 put highest value between that (i,j) in a new matrix, and if x(i,j)-y(i,j)>0 put the lowest value between that (i,j) in a new matrix, how can i do that? for example here: x-y= [-2 -2 2 1] because the first row and column of x-y in less than zero (-2), as a result in new matrix (like d) the first row and column must be the highest value between x(1,1) and y(1,1) and so on...,matrix d here would be d=[3 4 2 4]. hope to make sense

採用された回答

James Tursa
James Tursa 2015 年 11 月 13 日
xy = [x;y];
minxy = min(xy);
maxxy = max(xy);
g = x - y < 0;
d = x;
d(g) = maxxy(g);
d(~g) = minxy(~g);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by