Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

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

1 visualizzazione (ultimi 30 giorni)
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:

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by