Info
此问题已关闭。 请重新打开它进行编辑或回答。
Input Help
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2011-11-20
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 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!