Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Calculations on cell pairs that meet multiple pre-defined criteria?

1 回表示 (過去 30 日間)
John
John 2017 年 2 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
My goal: Depending on which of the 5 scenarios is prevalent in each row (cell pairs in red, see below), make the calculation following the if statement. End result should be 1 column, including the outcome of each row calc.
What I tried so far:
CalcOutcome = zeros(554,1);
for k=height(MomPF)
if MomPF.L_sum4t<0 & MomPF.U_sum4t>0
% make calc for every row but end result should only be 1 column
% with the calc outcomes
CalcOutcome=(-1)*MomPF.L_sum4t{k}*0.5 + MomPF.U_sum4t{k}*0.5;
elseif MomPF.L_sum4t<0 & MomPF.U_sum4t<0
CalcOutcome=(-1)*MomPF.L_sum4t{k}*1;
elseif MomPF.L_sum4t>0 & MomPF.U_sum4t>0
CalcOutcome=MomPF.U_sum4t{k}*1;
elseif MomPF.L_sum4t>0 & MomPF.U_sum4t<0
CalcOutcome=MomPF.L_sum4t{k}*0.5 + (-1)*MomPF.U_sum4t{k}*0.5;
elseif MomPF.L_sum4t==0 & MomPF.U_sum4t==0
CalcOutcome=0
end
end
Table:

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by