Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
I am Trying to Have User Input a single Var. But I Get This Error? Help?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
function [Y,T]=coopiem(t,tf,y,n)
prompt='Please enter a parameter, k: ';
t=0;
tf=24;
k=input(prompt);
y=yofk(k); %when k=0.2
n=36;
Y=y;
T=t;
h=(2/3);
for i=1:n; %figure how to do the interations
ye=y+(f(t,y))*h;
y=y+(1/2)*(f(t,y)+f((t+h),ye))*(2/3);
t=t+h;
Y=[Y;y];
T=[T;t];
Q=transpose([t;y]);
disp(Q);
end
I want to prompt the user to input a parameter k. But my initial y value (y0) is a function of k, because my initial time t (t0) is zero. How can I make it work?
1 comentario
Jan
el 14 de Oct. de 2017
What is the problem with the current version? You use y and n as inputs of the function, but overwrite it later.
Respuestas (1)
David Ding
el 17 de Oct. de 2017
Hi Felix,
I understand that you are receiving a "Not Enough Input Arguments" error. While I am not in a position to comment on the content of your code, I can point out that you are receiving your error because of your function "f.m". In "f.m", you are specifying three input arguments: "t", "y" and "k" as shown in the function declaration:
function coopiem = f(t, y, k)
However, in your script shown, you are calling "f" as follows:
f(t, y)
This will yield the error because you are calling "f" with two input arguments but it is expecting three. You need to supply the third argument, presumably some value corresponding to your "k".
Hope this helps,
David
0 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!