Advertisement
tomasfdel

Métodos Definiciones

Aug 24th, 2017
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.81 KB | None | 0 0
  1. #Rabalessons
  2.  
  3. function y = aplicar(f,var,x)
  4.     deff("z=F("+var+")","z="+f)
  5.     y = F(x)
  6. endfunction
  7.  
  8. function y = derivame(fun, var, orden, step, valor)
  9.     if orden == 0 then
  10.         y = aplicar(fun, var, valor)
  11.     else
  12.         deff("z = Pepe0("+var+")", "z =" + fun)
  13.         for i=1:orden-1
  14.             deff("z = Pepe"+string(i)+"("+var+")", "z = numderivative(Pepe"+string(i-1)+","+var+","+string(step)+",4)")
  15.         end;
  16.         deff("z = Fin("+var+")", "z = numderivative(Pepe"+string(orden-1)+","+var+","+string(step)+",4)")
  17.         y = Fin(valor)
  18.     end;
  19. endfunction
  20.  
  21.  
  22. #La llamada a la funcion fue algo como...
  23.  
  24. -->derivame("2*Carlos ** 2 + 5*Carlos + 3", "Carlos", 1, 0.01, 10)
  25.  ans  =
  26.  
  27.     45.  
  28.  
  29. -->derivame("2*Carlos ** 2 + 5*Carlos + 3", "Carlos", 2, 0.01, 10)
  30.  ans  =
  31.  
  32.     4.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement