martaczaska

Untitled

May 8th, 2021 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. % Lab 5.
  2. % Marta Trzaska 171632 SiSR
  3.  
  4. function [u_C, i_L] =euler(x_0, funkcja, t, h)
  5. global C L E R;
  6. t_h = t/h;
  7. u_C = zeros(1, t_h + 1);
  8. i_L = zeros(1, t_h + 1);
  9.  
  10. u_C(1) = x_0(1)
  11. i_L(1) = x_0(2)
  12.  
  13. for i=2:(length(t_h)+1)
  14. if(i == 1)
  15.  
  16. elseif(i > 1)
  17. [f_uC, f_iL] = funkcja(C, i_L(i-1), L, E, R, u_C(i-1));
  18. u_C(i) = u_C(i-1) + h*f_uC;
  19. %x_i(:,i) = x;
  20. i_L(i) = i_L(i-1) + h*f_iL;
  21. end
  22. end
  23.  
  24. end
  25.  
Add Comment
Please, Sign In to add comment