Input Help
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Hello, this is my Eulers methods program. I am trying to make the user input an equation. For example, I want the user to input something like (x+y). However, I have the user to also input starting values of and x and y. When the user inputs these x and y values, it makes the (x+y) a constant. However, the values of x and y change which in turn should change the value of (x+y). But because it changed dydx to a constant originally, the value of (x+y) doesn't change even though it should. Here is my program so far. I've gotten advice to change the input to input s but I don't really know how that works. Could someone possibly edit my code so that it will do what it is supposed to? I'm hoping that if someone edits it correctly, i can understand what is going on. Thank you.
x=input('Input the initial value of "x": ');
y=input('Input the initial value of "y": ');
dydx=input('The change in y in terms of x is equal to: ','s');
value=input('Input the value of the unknown function in which you want to evaluate to. (i.e if you want y(3), type in 3) \n');
step=input('Input the step size you would like: ');
for i=0:100
dy=dydx*step;
x=x+step;
y=y+dy;
if x==value
fprintf('The estimated value of the function is %3.2f \n',y)
end
end
Respuestas (1)
Walter Roberson
el 20 de Nov. de 2011
0 votos
I already gave you a specific reference to the code change you need in your existing thread on this topic, http://www.mathworks.com/matlabcentral/answers/21656-eulers-formula-program-help
1 comentario
Teague
el 20 de Nov. de 2011
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!