Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Input Help

2 Ansichten (letzte 30 Tage)
Teague
Teague am 20 Nov. 2011
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (1)

Walter Roberson
Walter Roberson am 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 Kommentar
Teague
Teague am 20 Nov. 2011
Yes you did. I'm still having a difficult time after reading through the link you sent me. I'm sorry,

Diese Frage ist geschlossen.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by