Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Too many output arguments.Why i am getting this issue

1 visualización (últimos 30 días)
Sohaib naeem
Sohaib naeem el 4 de Dic. de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
function [T,Y] = taylor(f,a,b,ya,m)
syms t y
dfs(1) = symfun(f, [t y]);
for k=1:3
dfs(k+1) = diff(dfs(k),t)+f*diff(dfs(k),y);
end
df = matlabFunction(symfun(dfs,[t y]));
h = (b - a)/m;
T = zeros(1,m+1);
Y = zeros(1,m+1);
T(1) = a;
Y(1) = ya;
for j=1:m
tj = T(j);
yj = Y(j);
D = df(tj,yj);
Y(j+1) = yj + h*(D(1)+h*(D(2)/2+h*(D(3)/6+h*D(4)/24)));
T(j+1) = a + h*j;
end
end
and i m solving f=y-t^2+1
  1 comentario
Image Analyst
Image Analyst el 4 de Dic. de 2016
Why didn't you include the error message? You included only a small, virtually useless part of it. Please include ALL THE RED TEXT, after you read this if course. Also show the code you use to call your taylor() function.

Respuestas (2)

Tamir Suliman
Tamir Suliman el 5 de Dic. de 2016
I m not sure exactly but check this code I think you might some thing you initalize to sum the variables then store it again to add it next time
function [T,Y] = taylor(f,a,b,ya,m)
syms t y
dfs(1) = symfun(f, [t y]);
for k=1:3
dfs(k+1) = diff(dfs(k),t)+f*diff(dfs(k),y)
end
df = matlabFunction(symfun(dfs,[t y]));
h = (b - a)/m;
T = zeros(1,m+1);
Y = zeros(1,m+1);
T(1) = a;
Y(1) = ya;
tj=0;yj=0;
for j=1:m
D = df(tj,yj);
Y(j+1) = yj + h*(D(1)+h*(D(2)/2+h*(D(3)/6+h*D(4)/24)));
T(j+1) = a + h*j;
tj = T(j);
yj = Y(j);
end
Tj=tj
Yj=yj

Image Analyst
Image Analyst el 5 de Dic. de 2016
My guess is you called it expecting 3 output arguments, like this:
[T, Y, thirdArg] = taylor(f,a,b,ya,m);
but your code only returns T and Y, not thirdArg.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by