Info
This question is closed. Reopen it to edit or answer.
Input Help
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 20 Nov 2011
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 Comment
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!