Help Calling a Function

4 visualizaciones (últimos 30 días)
Alex
Alex el 6 de Dic. de 2014
Respondida: Image Analyst el 6 de Dic. de 2014
The following is my .m file. I have the reaeration function working fine. It is just the deOxygen function that will not work. I get the following error when trying to run the program: "Warning: File: myHW7.m Line: 21 Column: 24 Function with duplicate name "deOxygen" cannot be called."
Any suggestions? Thanks in advance Alex
function constant = reaeration(array)
function resultarray = deOxygen(array , constant)
load PollutionData.txt;
array = PollutionData(:,1);
timearray = (0:.5:250);
constant = reaeration(array)
resultarray = deOxygen(array , constant)
return
function constant = reaeration(array)
constant = ((array(5,:) .* array(3,:)) .^ 0.5) ./ (array(4,:) .^ 1.5);
return
function resultarray = deOxygen(array , constant)
array(3,:) = array(3,:) .* 0.001076; %conversion
array(6,:) = array(6,:) .* 0.0002778; %conversion
for i = 250: 0.5: 0, do, end
resultarray = (((array(6,:) .* array(2,:)) ./ (constant - array(6,:)) .* (exp(-array(6,:) * i * 3600) - exp(-constant .* i .* 3600)) + (array(1,:) * exp(-constant .* i .* 3600))));
return

Respuesta aceptada

Image Analyst
Image Analyst el 6 de Dic. de 2014
You can't start out myHW7.m with these lines:
function constant = reaeration(array)
function resultarray = deOxygen(array , constant)
Those are function definitions which you define later in the m-file. So you're basically doing it twice and the first time you define them there's not even any body to the function. So, I assume you just want to call them, but to call them you need a function line with myHW7 in it:
function myHW7()
load PollutionData.txt;
array = PollutionData(:,1);
timearray = (0:.5:250);
% Now call (not define) the functions
constant = reaeration(array)
resultarray = deOxygen(array , constant)
return
% Now define other functions like reaeration() and deOxygen()

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by