Too many output error message when using function in a for loop
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am getting the "too many output arguments" error message when calling on a function that's within a for loop. heres my code.
function RFtable(lowerm2bound, upperm2bound, m2step, gamma, m_1);
n=(upperm2bound-lowerm2bound)/m2step;
m2values=linspace(lowerm2bound,upperm2bound,n)
for i=1:n+1
poverpstar(i)= RFp2overp1(gamma,m_1,m2values(i))
end
end
I stepped though the script and the error is occurring within the for loop. here's the code for the RFp2overp1 function.
function RFp2overp1(gamma,m_1,m_2)
(1+gamma*m_1^2)/(1+gamma*m_2^2)
end
Any advice would be great I think its something pretty simple.
0 comentarios
Respuestas (1)
Rajanya
hace alrededor de 8 horas
The error occurs because the function ‘RFp2overp1’ does not return a value, but the following line in your code expects it to do so:
poverpstar(i)= RFp2overp1(gamma, m_1,m2values(i))
You can modify ‘RFp2overp1’ to include an output argument, which should fix this error.
function res = RFp2overp1(gamma, m_1,m_2)
res = (1+gamma*m_1^2)/(1+gamma*m_2^2)
end
Thanks!
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!