Advertisement
martaczaska

euler.m

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