I have two matrices the same size 'F1result' and 'F2result'. I need to compare them element by element and create a new matrices 'F' with whichever value is greater.

1 回表示 (過去 30 日間)
[M,N] = size(MagGridForceAX); % Establish dimensions for row and column loop counters
for i = 1:M
for j = 1:N
% Creates coefficients for the simultaneous equations of F1 and F2
% based on sum of x and sum of y forces equalling zero
CoefficientMatrix = [MagGridForceAX(i,j) MagGridForceBX(i,j); MagGridForceAY(i,j) MagGridForceBY(i,j)];
% Forces Matrix solving for forces in beams in each x and y
% coordinate
ForcesMatrix = CoefficientMatrix\P;
F1result(i,j) = ForcesMatrix(1);
F2result(i,j) = ForcesMatrix(2);
end
end

採用された回答

dpb
dpb 2022 年 9 月 18 日
F=max(F1,F2);

その他の回答 (1 件)

William Rose
William Rose 2022 年 9 月 18 日
F1res=rand(3,3), F2res=rand(3,3)
F1res = 3×3
0.2365 0.9271 0.3496 0.0122 0.3467 0.8742 0.3531 0.4970 0.5388
F2res = 3×3
0.9900 0.9559 0.2499 0.7560 0.2592 0.8225 0.5928 0.6783 0.7452
Fmaxres=max(F1res,F2res)
Fmaxres = 3×3
0.9900 0.9559 0.3496 0.7560 0.3467 0.8742 0.5928 0.6783 0.7452
It works.
  5 件のコメント
Sean Flanagan
Sean Flanagan 2022 年 9 月 19 日
Thanks DB for the help with this. I needed to restore the negative.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by