Hello guys.. I am currently doing project on raw data analysis of smell pattern.. the data is being analysed via pca,hca, and lda.. I already completed on PCA.. I need your help on HCA as it shows dimension mismatcH. tHIS IS MY PROGRAM.
1 view (last 30 days)
Show older comments
clear all; clear; clc
%call data d1=xlsread('amb010611.csv');
d2=xlsread('banana010611.csv');
d3=xlsread('rose010611.csv');
d4=xlsread('strawberry010611.csv');
d5=xlsread('Vanilla010611.csv');
%filter data
data1 = d1(101:600,1:12);
data2 = d2(101:600,1:12);
data3 = d3(101:600,1:12);
data4 = d4(101:600,1:12);
data5 = d5(101:600,1:12);
%filter data for 500 samples, from 1 to 12 sensor.
%digital filter data
data1s=sgolayfilt(data1,2,11);
data2s=sgolayfilt(data2,2,11);
data3s=sgolayfilt(data3,2,11);
data4s=sgolayfilt(data4,2,11);
data5s=sgolayfilt(data5,2,11);
%average mean data ambience
mean_data1s=mean(data1s);
%average mean data ambience minus with data collected
k2=size(data2s); coloum2=k2(2); rows2=k2(1); for i = 1:rows2 for j=1:coloum2 data2bl(i,j)= data2s(i,j) - mean_data1s(1,j); end end
k3=size(data3s); coloum3=k3(2); rows3=k3(1); for i = 1:rows3 for j=1:coloum3 data3bl(i,j)= data3s(i,j) - mean_data1s(1,j); end end
k4=size(data4s); coloum4=k4(2); rows4=k4(1); for i = 1:rows4 for j=1:coloum4 data4bl(i,j)= data4s(i,j) - mean_data1s(1,j); end end
k5=size(data5s); coloum5=k5(2); rows5=k5(1); for i = 1:rows5 for j=1:coloum5 data5bl(i,j)= data5s(i,j) - mean_data1s(1,j); end end
%PCA comparison
x = [data2bl;data3bl;data4bl;data5bl];
[alfa,pc,eigcov,tsq] = princomp(x);
percent_explained = 100*eigcov/sum(eigcov); PC1 = percent_explained(1) PC2 = percent_explained(2)
%PCA plotting
figure(11); plot(pc(1:500,1), pc(1:500,2),'ro');hold on;
plot(pc(501:1000,1), pc(501:1000,2),'b*');
plot(pc(1001:1500,1), pc(1001:1500,2),'ks');
plot(pc(1501:2000,1), pc(1501:2000,2),'y>'); %
%PCA percentage plotting title('2D PCA Plot');
xlabel('PC1 (87.2567%)');
ylabel('PC2 (10.1872%)');
grid on;
h = legend('Banana','Rose','Strawberry','Vanilla',2);
%HCA PROGRAMMING
z=zeros(250,10); z=[data2bl(1:50,:); data3bl(1:50,:); data4bl(1:50,:); data5bl(1:50,:);]; for index=1:50 Origin(index,:)='Banana'; end for index=51:100 Origin(index,:)='Rose'; end for index=101:150 Origin(index,:)='Strawerry'; end for index=151:200 Origin(index,:)='Vanilla'; end
%Dendrogram plot figure(12) [d,p,stats]= manova1(z,Origin); manovacluster(stats,'single'); title('Dendrogram plot of Basic Smell'); ylabel('Similarity level'); xlabel('Sample type') grid on; h=legend('Banana','Rose','Strawberry','Vanilla',2);
0 Comments
Answers (0)
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!