Advertisement
PanaPatryk44

matlab zad2

Nov 26th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. %Liniowy model wzrostu – czas dyskretny
  2. a1=1.2
  3. a2=1
  4. a3=0.8
  5. start=1 %wartosć początkowa
  6. z=10 % ilość czasu
  7.  
  8. x=0:1:z
  9. y1=x
  10. y2=x
  11. y3=x
  12. y1(1)=start
  13. y2(1)=start
  14. y3(1)=start
  15. for i=2:(z+1)
  16. y1(i)=y1(i-1)*a1
  17. y2(i)=y2(i-1)*a2
  18. y3(i)=y3(i-1)*a3
  19. end
  20. % hold on
  21. %plot(x,y1,x,y2,x,y3)
  22. %hold off
  23.  
  24. figure
  25. hold on
  26. stem(x,y1)
  27. stem(x,y2,':diamondr')
  28. stem(x,y3,'filled')
  29. hold off
  30.  
  31. %Liniowy model wzrostu – czas ciągły
  32. b1=2
  33. b2=0
  34. b3=-2
  35. start=1 %wartosć początkowa
  36. z=1 % ilość czasu
  37.  
  38. x1=0:0.01:z
  39. y1_1=x1
  40. y2_1=x1
  41. y3_1=x1
  42. y1_1(1)=start
  43. y2_1(1)=start
  44. y3_1(1)=start
  45. for i =2:length(x1)
  46. y1_1(i)=start*exp(b1*x1(i))
  47. y2_1(i)=start*exp(b2*x1(i))
  48. y3_1(i)=start*exp(b3*x1(i))
  49. end
  50.  
  51. figure
  52. plot(x1,y1_1,x1,y2_1,x1,_y3_1)
  53. grid on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement