`clear all, close all, clcfilename = 'PCA1.xlsx';a = xlsread(filename,"CAP",'B:B')b = xlsread(filename,"CAP",'C:C')X = bsxfun(@minus,a,mean(a))Y = bsxfun(@minus,b,mean(b))Z = [X,Y][U,S,V] = svd(Z,"econ")figuresubplot(1,2,1)semilogx(diag(S),'k-o','LineWidth',2.5)set(gca,'FontSize',15), axis tight, grid onsubplot(1,2,2)plot(cumsum(diag(S))./sum(diag(S)),'k-o','LineWidth',2.5)set(gca,'FontSize',15), axis tight, grid onset(gcf,'Position',[1400 100 3*600 3*250])figure, hold onfor i=1:size(Z,1) x = V(:,1)'*Z(i,:)'; y = V(:,2)'*Z(i,:)'; plot(x,y,'r-o','LineWidth',3) xlabel('PC1') ylabel('PC2') view(85,25), grid on, set(gca,'FontSize',15) set(gcf,'Position',[1400 100 1200 1600])end`

# MATLAB: Hello, I was wondering why the last figure in this code keeps giving me a 3D graph instead of a 2D

plotting

###### Related Question

- How to add XTickLabels in a subplot (2014a)
- How to create a program that reads a matrix array and returns me a second matrix composed of zeros and the main diagonal of the first matrix
- How to turn vertical to horizontal
- How to get the secondary diagonal of a matrix
- How to Sum matrix diagonals
- Black axes for yyaxis (not default blue and orange)
- How can i use legend command when i am using hold on for plotting graphs? in the plot i want to use legend command to indicate the color for respective plot that is black for low pass,blue for high pass,green for power complementary,red for all pass.

## Best Answer