フィルターのクリア

how to compair two vectors element wise and exchange the biger element with the small elements of two vectors

1 回表示 (過去 30 日間)
I want to compare two vectors element wise (A and B of the same size)that user may feed to my code randomly.I want all elements in A should greater than corresponding element in B. and if there are big elements in B i want to exchange that element with element in A with the same position.Is there any one can help me? eg A=[4 5 10 8 9] B=[1 6 9 9 7] in A 5<6 and 8 <9 in second and 4th position.I need to exchange 6 with 5 and 8 with 9

採用された回答

Roger Stafford
Roger Stafford 2014 年 7 月 25 日
X = sort([B;A],1);
B = X(1,:);
A = X(2,:);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMotor Drives についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by