Info
This question is closed. Reopen it to edit or answer.
Calculations on cell pairs that meet multiple pre-defined criteria?
1 view (last 30 days)
Show older comments
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 Comments
Answers (0)
This question is closed.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!