in the code below I'm trying to get an output vector FOR all the IF results for each value, 0 to 0.25 in steps of 0.001, in O3ppm.
At present I've only been able to get one output which is BPlo=0.065, the second IF output.
I'd like to see; BPlo=[n, n1, n2....nx] if that makes sense.
Any help would be greatly appreciated.
This section of code is part of a larger script for an Honours year project looking at Air Quality Monitoring.
Graeme.
O3ppm=[0:0.001:0.25];
for O3ppm=[]
if O3ppm < 0.065
BPlo = 0
elseif (O3ppm >= 0.065)&&(O3ppm < 0.085)
BPlo = 0.065
elseif (O3ppm >= 0.085)&&(O3ppm < 0.105)
BPlo = 0.085
elseif (O3ppm >= 0.105)&&(O3ppm < 0.125)
BPlo = 0.105
elseif (O3ppm >= 0.125)
BPlo = 0.125
end
end
BPlo
Well you are only ever setting BPlo
equal to a scalar, so it won't be a vector.
Since you already have written all the conditionals, intialise BPlo
before the for
loop with
BPlo=zeros(size(O3ppm));
and replace the for O3ppm=[]
with
for i=1:length(03ppm)
and then replace any instance of BPlo=
with BPlo(i)=
, and any instance of O3ppm
with O3ppm(i)
.
I'm sure there is a cleaner way of doing all the conditionals rather than using a bunch of elseif
's, but if you code runs quickly enough then it doesn't matter.
In the first line of your code you set O3ppm
to a vector of 251 values:
O3ppm=[0:0.001:0.25];
and in the next line you set it to an empty vector
for O3ppm=[]
I haven't studied the rest of your code, I think you should fix this first problem first. It's not entirely clear what the fix should be.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.