Advertisement
Guest User

Question 1 et question 2

a guest
Mar 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.08 KB | None | 0 0
  1. clear all
  2. close all
  3.  
  4.  
  5. % Paramètres
  6.  
  7. a=1; %arbitraire
  8. b=3; %arbitraire
  9.  
  10. % Paramètres D1
  11. x1=[0:0.01:1];
  12. xi1=rand(1,101);  
  13. eps1=(b/10)*(2*xi1-1);
  14.  
  15. % Paramètres D2
  16. x2=[0:0.05:1]
  17. xi2=rand(1,21);  
  18. eps2=(b/2)*(2*xi2-1)
  19.  
  20. %Question 1 :
  21.  
  22. % Création de la matrice D1, contenant les coordonnées des cent points
  23. for (i=1:101)
  24.     Y1(1,i)=a*x1(1,i)+b+eps1(1,i);
  25. end
  26. D1=[x1;Y1];
  27. c=[0.69,0.48,0.83];
  28. scatter(x1,Y1,15,c,'filled')
  29. hold on
  30.  
  31. % Création de la matrice D2, contenant les coordonnées des vingt points
  32. % absurdes
  33. for (i=1:21)
  34.     Y2(1,i)=a*x2(1,i)+3*b+eps2(1,i);
  35. end
  36. D2=[x2;Y2];
  37. c=[0.1,0.2,0];
  38. scatter(x2,Y2,15,c,'filled')
  39.  
  40. % Création de D3, utilisée par la suite pour M
  41. D3 = horzcat(D1,D2)
  42. for (i=1:122)
  43.     x3(1,i)=D3(1,i)
  44.     Y3(1,i)=D3(2,i)
  45. end
  46. c=[1,0,0];
  47. figure(2)
  48. scatter(x3,Y3,15,c,'filled')
  49.  
  50. % Question 2 :
  51.  
  52. M0=ones(1,122);
  53. Mh=[M0;x3];
  54. Mv=transpose(Mh);
  55. Y3v=transpose(Y3);
  56.  
  57. Q=Mh*Mv
  58. S=Mh*Y3v
  59.  
  60. P=inv(Q)*S
  61. B1=P(1,1)
  62. A1=P(2,1)
  63.  
  64. for (i=1:122)
  65.    Y3d(1,i)=A1*x3(1,i)+B1
  66. end
  67. c=[0,1,0];
  68. figure(3)
  69. scatter(x3,Y3d,15,c,'filled')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement