Advertisement
Guest User

A31

a guest
May 24th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.72 KB | None | 0 0
  1. // Zadanie A31
  2. // funkcja wykres
  3. function wykres
  4.   a=2e-4; b=3e-5; Us=1.25; E=30; R=2.2e3;
  5.   x=linspace(0,35,300);
  6.   r=E/R-x/R;
  7.   y1=a.*x.^5.*e.^(-x./Us)+b.*x.^(3/2);
  8.   plot(x,r,'r',x,y1,'b'),grid
  9.  
  10. // funkcja f
  11. function i=f(U)
  12.   a=2e-4; b=3e-5; Us=1.25; E=30; R=2.2e3;
  13.   i=a.*U.^5.*e.^(-U./Us)+b.*U.^(3/2)-E./R+U./R;
  14.  
  15. // funkcja fprim
  16. function i=fprim(U)
  17.   a=2e-4; b=3e-5; Us=1.25; E=30; R=2.2e3;
  18.   i=5*a.*U.^4*e.^(-U./Us)+a.*U.^5*e.^(-U./Us).*(-1/Us)+3/2*b.*U.^(-1/2)+1/R;
  19.  
  20. // funkcja newton
  21. function [U0,I0,k]=newton(U,delta)
  22.   E=30; R=2.2e3;
  23.   k=1;
  24.   while (abs(f(U)) > delta)
  25.     U=U - f(U) / fprim(U);
  26.     k=k+1;
  27.     if(k>50)
  28.       'za duzo'
  29.       return;
  30.     end
  31.   end
  32.   U0=U;
  33.   I0=E/R-U/R;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement