Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all
- close all
- % Paramètres
- a=1; %arbitraire
- b=3; %arbitraire
- % Paramètres D1
- x1=[0:0.01:1];
- xi1=rand(1,101);
- eps1=(b/10)*(2*xi1-1);
- % Paramètres D2
- x2=[0:0.05:1]
- xi2=rand(1,21);
- eps2=(b/2)*(2*xi2-1)
- %Question 1 :
- % Création de la matrice D1, contenant les coordonnées des cent points
- for (i=1:101)
- Y1(1,i)=a*x1(1,i)+b+eps1(1,i);
- end
- D1=[x1;Y1];
- c=[0.69,0.48,0.83];
- scatter(x1,Y1,15,c,'filled')
- hold on
- % Création de la matrice D2, contenant les coordonnées des vingt points
- % absurdes
- for (i=1:21)
- Y2(1,i)=a*x2(1,i)+3*b+eps2(1,i);
- end
- D2=[x2;Y2];
- c=[0.1,0.2,0];
- scatter(x2,Y2,15,c,'filled')
- % Création de D3, utilisée par la suite pour M
- D3 = horzcat(D1,D2)
- for (i=1:122)
- x3(1,i)=D3(1,i)
- Y3(1,i)=D3(2,i)
- end
- c=[1,0,0];
- figure(2)
- scatter(x3,Y3,15,c,'filled')
- % Question 2 :
- M0=ones(1,122);
- Mh=[M0;x3];
- Mv=transpose(Mh);
- Y3v=transpose(Y3);
- Q=Mh*Mv
- S=Mh*Y3v
- P=inv(Q)*S
- B1=P(1,1)
- A1=P(2,1)
- for (i=1:122)
- Y3d(1,i)=A1*x3(1,i)+B1
- end
- c=[0,1,0];
- figure(3)
- scatter(x3,Y3d,15,c,'filled')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement