Here is the code:
load PollutionData.txt;array = PollutionData(:,1); %#ok<NODEF>
timearray = (0:.5:250);timearray = reshape(timearray,[],1);constant = reaeration(array);array(3,:) = array(3,:) .* 0.001076; %conversion
array(6,:) = array(6,:) .* 0.0002778; %conversionresultarray = deOxygen(array , timearray, constant);plot(timearray(:,1) , resultarray(:,1))returnfunction constant = reaeration(array)constant = ((array(5,:) * array(3,:)) ^ 0.5) / (array(4,:) .^ 1.5);returnfunction resultarray = deOxygen(array , timearray, constant)resultarray = zeros(1,1000);for a = (0:.5:250) resultarray(a) = (((array(6,:) * array(2,:)) / (constant - array(6,:))) * (exp(-array(6,:) * timearray(a) * 3600) - exp(-constant * timearray(a) * 3600))) + (array(1,:) * exp(-constant * timearray(a) * 3600));endreturn
I'm getting in error in the deOxygen function at the "resultarray(a) = (((…" portion. Also, the two following errors also appear:
Attempted to access timearray(0); index must be a positive integer or logical.
Error in myHW7 (line 15) resultarray = deOxygen(array , timearray, constant);
And I have no idea why. Any ideas?
Thanks
Best Answer