Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
John
John el 15 de Feb. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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:

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by