Error: Too many outputs to function

I'm a student in an entree level programming class.
I'm using Freemat just in case that becomes a problem, but I have a hopefully simple question In my main script,
for i=2:5
T(i)=nodeTemperature(i,T,h);
end
then in the nodeTemperature script,
function nodeTemperature(i,T,h)
evalin('base','T(i-1) + T(i+1) + (h^2)*B*Ts / ( (h^2)*B+2)');
is giving me "Too many outputs" I've defined h and B already in my script and when I type out for instance "nodeTemperature(2,T,h)" in the command window it returns the value I am expecting. But when I try to set it equal to T(i)it gives me the error. I'm required to have the "T(i)" be defined by a function using evalin inside the function. I've gotten it to work when I eliminated the function but I won't get credit for the assignment.
I'm really really new to this and I could use the help, thanks

 Réponse acceptée

Walter Roberson
Walter Roberson le 28 Avr 2014
Modifié(e) : Walter Roberson le 28 Avr 2014
function r = nodeTemperature(i,T,h)
B = evalin('base', 'B');
Ts = evalin('base', 'Ts');
r = T(i-1) + T(i+1) + (h^2) * B*Ts / ( (h^2)*B+2));

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Parallel Server dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by