Advertisement
miklis

Untitled

May 16th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. prompt = 'What is the original function? '
  2. x=linspace(-3,3,601)
  3. e=2.718281828
  4. t=input(prompt) %function saved as string
  5. eval(strcat('y=',t))
  6. prompt2 = 'What is the derivative? ';
  7. eval(strcat('z=',input(prompt2)))
  8. %'e.^(-x.*x)-1'
  9. %'-2*e.^(-x.*x).*x'
  10. figure
  11. plot(x,x,x,y)
  12. title('Relaksacijos metodas')
  13. xlabel('x')
  14. ylabel('g(x)')
  15. figure
  16. plot(x,z)
  17. title('Isvestine')
  18. xlabel('x')
  19. ylabel('g`(x)')
  20. start='Type startpoint'
  21. eval(strcat('x=',input(start)))
  22. eval(strcat('x1=',t))
  23. array=[x x1]
  24. eval(strcat('eps=',input('Type epsilon')))
  25. while abs(array(end)-array(end-1))>eps
  26. x=array(end)
  27. eval(strcat('x1=',t))
  28. array=[array x1]
  29. end
  30. figure
  31. plot(array)
  32. title('Tasko artejimas')
  33. xlabel('zingsniai')
  34. ylabel('taskas')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement