mercredi 20 février 2019

Issue Using Multiple Criteria in If-Statements in MATLAB

I'm having an issue where, for the first for loop I'm getting my desired output at no2_iterate(1) but within the second loop made to generate no2_iterate(2) I'm not getting any output whatsoever.

The following are my two if-statements/for loops to generate no2_iterate(1) & (2).

no2_sum_1cm = 0;
gridh_iterate = 0 % starting height in cm
lato = 1;
lono = 1;
no2_iterate_start = 0;
no2_iterate(1:2) = 0;

if gridh_iterate < gridh(lato,lono,1);
    no2_layer = no2_moleccm3(lato,lono,1,12);
    for i = 1:gridh(lato,lono,1);
        for h = 1;
            gridh_iterate = gridh_iterate+ 1; % in cm, now compare to gridh(1,1,1) and the other areas, so if its over the height of the cell switch no2 concn
        end
        no2_iterate(1) = (no2_iterate(1) + no2_layer)*1; % Now units of g no2/cm2
    end
    no2_iterate = no2_iterate
end

if gridh_iterate < gridh(lato,lono,2) && gridh_iterate >gridh(lato,lono,1);
    no2_layer = no2_moleccm3(lato,lono,2,12);
    for i = 1:gridh(lato,lono,2);
        for h = 1;
            gridh_iterate = gridh_iterate + 1; % in cm, now compare to gridh(1,1,1) and the other areas, so if its over the height of the cell switch no2 concn
        end
        no2_iterate(2) = (no2_iterate(2) + no2_layer)*1; % Now units of g no2/cm2
    end
    no2_iterate = no2_iterate;
end

I suspect that my issue is within the second if-statement where I specify that I want the range to be between two separate variables that I am somehow excluding all variables.

Aucun commentaire:

Enregistrer un commentaire