PRINCIPALES
Travaux Pratiques
Réalisé par :
DAHMI YASSINE
Encadré par :
Pr. RABIE REDA
1-charger le fichier.
Le script :
df=xlsread('TP_fruit(1).xlsx')
x=df(2:287,4:688)
Y=df(1,4:688)
Le plot :
Le script :
figure(11);plot(Y',x(120:180,:)')
Le plot :
Le script :
spectremoyenne=mean(x);
sdspectre=std(x);
Le script :
spectremoyenneplusSD=spectremoyenne+sdspectre;
spectremoyennemoinsSD=spectremoyenne-sdspectre;
figure(12);plot(Y',spectremoyenne',Y',spectremoyenneplusSD',Y',spectremoyen
nemoinsSD')
Le plot :
7- Déterminer la hauteur maximale du signal.
hauteurmaximal=max(x(:));
##SVN
Le script :
function [xsnv]=snv(x)
[m,n]=size(x);
xsnv=((x-mean(x')'*ones(1,n))./(std(x')'*ones(1,n)))
figure(5);plot(xsnv')
figure(6);plot(mean(xsnv)',xsnv)
end
Le plot :
##MSC
function [xmsc,me,p]=msc1(x)
first=1;
last=length(x(1,:));
[m,n]= size(x);
me=mean(x);
for i=1:m
p=polyfit(me(first:last),x(i,first:last),1)
xmsc(i,:)=(x(i,:)-p(2)*ones(1,n))./(p(1)*ones(1,n));
end
figure(3);plot(xmsc')
figure(4);plot(mean(xmsc)',xmsc')
imagesc(corr(x))
colormap(jet)
end
Le plot :
## Réduction de la non-normalité
Le script :
function [logpr]=logp(x)
b=1./x
logpr=log(b)
figure(7);plot(logpr')
figure(8);plot(mean(logpr)',logpr');
Le plot :
C) Analyse en composante principale:
Le script :
function [Score,Loading,E,vr,moy,SD]=acp(X,Center,Scale)
%centrer les données
moy=mean(X);
SD=std(X);
if Center == true
%centrer les données
[n,a]=size(X);
moy=mean(X);
Xmoy=moy(ones(n,1),:);
Xc=X-Xmoy;
MAT=Xc;
[n,a]=size(X);
moy=mean(X);
Xmoy=moy(ones(n,1),:);
Xc=X-Xmoy;
SD=std(X);
Xsd=SD(ones(n,1),:);
Xcr= Xc./Xsd;
MAT= Xcr;
else
MAT=X;
end
% SVD decomposition
[V h U]=svd(MAT);
% rsultats
Score =V*h;%Matrice des scores
Loading = U;% Les loadings
P=U;% Vecteur vecteur propre
E=MAT-((V*h)*U');% Matrice de Resud des résidus
vr=diag(h);