function stemz(X,C,P,L,M) % STEMZ Discrete sequence plot for complex values in 3D % STEMZ(C) plots the complex data sequence C as stems from % the x axis onto a complex plane formed by the y and z axes. % % STEMZ(X,C) plots the values in C at the points in X. % % STEMZ(X,C,1) includes projections onto real and imag planes % % STEMZ(X,C,0,'r','rx') plots values in C at points in X without % projections, with red stems and red Xs at the end of the stems. % % 2000-09-01 dpwe@ee.columbia.edu % Argument handling if (nargin < 4) L = 'b-'; M = 'bo'; end if (nargin < 3) P = 0; end if (nargin < 2) C = X; X = 1:length(C); end N = length(C); showprojs = P; % Plot the X origin plot3([min(X);max(X)], [0;0], [0;0], 'k-'); hold on % Plot the Re,Im axes (if visible) if min(X) <= 0 & max(X) >= 0 plot3([0;0],[min(real(C));max(real(C))],[0;0], 'k-'); plot3([0;0],[0;0],[min(imag(C));max(imag(C))], 'k-'); end z = zeros(1,N); % Construct the line segments plot3([X;X],[z;real(C)],[z;imag(C)],L); plot3(X,real(C),imag(C),M); if showprojs % Add projections onto real and imag ytk = get(gca,'YTick'); yy = ytk(end)*ones(1,N)-eps; plot3([X;X], [yy;yy], [z;imag(C)], 'c-'); ztk = get(gca,'ZTick'); zz = ztk(1)*ones(1,N)+eps; plot3([X;X], [z;real(C)], [zz;zz], 'r-'); end hold off % Annotation xlabel('n'); ylabel('Real'); zlabel('Imag'); grid on % Make it interactively rotatable rotate3d on % Favorite default viewpoint - from the front % az = 40 deg, el = 30 deg view(40,30);