Error using feval Argument must contain a string or function_handle.
조회 수: 6 (최근 30일)
이전 댓글 표시
a=input('ingresa el inicio del dominio de t:');
b=input('ingresa el fin del dominio de t:');
n=input('ingresa el # de particiones del dominio t:');
h=(b-a)/n;
t=a:h:b; %dominio
f=input('ingresa la función completa a resolver:');
y0=input('ingresa la condición inicial para y:');
%variables de Euler
y=zeros(1,n+1);%reservamos memoria
y(1)=y0;
for i=1:length(t)-1
y(i+1)=y(i)+h*feval(f,t(i),y(i));
end
figure (1)
xlabel ('X')
ylabel('Y')
plot(t,y)
댓글 수: 0
답변 (1개)
Jan
2018년 6월 3일
After
f = input('ingresa la función completa a resolver:')
the variable f contains numerical values. Either use
f = input('ingresa la función completa a resolver:', 's')
or much better: Define the function by code, not by an input command. If the user provides the data by input, it is hard and tedious to repeat the evaluation. In consequence this impedes debugging. Prefer to write a function and define the data as input arguments.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!