📄 eigplot1.m
字号:
function eigValsOut = eigplot1(corrMatIn, scaleType, plotType, plotOpt)%EIGPLOT1 Plots the eigenvalues of correlation matrices.%%--------%Synopsis:% eigValsOut = eigplot1(corrMatIn)% eigValsOut = eigplot1(corrMatIn, scaleType, plotType, plotOpt)%%Description:% Plots the eigenvalues of one or more correlation matrices.%%Output and Input:% eigValsOut (CxMatrixT): The calculated eigenvalues. Each row comes from% a correlation matrix.%% corrMatIn (RxCorrMatT or Vector of RxCorrMatT): Correlation matrix(ces)% to plot the igenvalues for. The data type of "corrMatIn" is either% RxCorrMatT or cell array of RxCorrMatT.% scaleType [D](StringT) : Scale Type for vertical axis.% = 'lin': Linear scale (power).% = 'dB': dB scale. (default)% plotType [D](StringT):% = 'bar': Vertical bar plot. (default)% = 'barh': Horizontal bar plot.% = 'bar3': 3D bar plot.% = 'plot': Using MATLAB's "plot" function.% = 'stem': Using MATLAB's "stem" function.% = 'stairs': Using MATLAB's "stairs" function.% plotOpt [D](StringT): Plot options passed on to the plotting function.%%--------%Notations:% Data type names are shown in parentheses and they start with a capital% letter and end with a capital T. Data type definitions can be found in [1]% or by "help dbtdata".% [D] = This parameter can be omitted and then a default value is used.% When the [D]-input parameter is not the last used in the call, it must be% given the value [], i.e. an empty matrix.% ... = There can be more parameters. They are explained under respective% metod or choice.%%Examples:%%Software Quality:% (About what is done to ascertain software quality. What tests are done.)%%Known Bugs:%%References:% [1]: Bj鰎klund S.: "DBT, A MATLAB Toolbox for Radar Signal Processing.% Reference Guide", FOA-D--9x-00xxx-408--SE, To be published.%%See Also:% basecorrm, ecorrm% * DBT, A Matlab Toolbox for Radar Signal Processing *% (c) FOA 1994-2000. See the file dbtright.m for copyright notice.%% Start : 980611 Svante Bj鰎klund (svabj).% Latest change: $Date: 2000/10/16 15:20:51 $ $Author: svabj $.% $Revision: 1.10 $% *****************************************************************************% ----------------------------------------------------------------------- %% Handle input parameters% ----------------------------------------------------------------------- %if (nargin < 1) error('DBT-Error: To few input parameters.')end% ****************** Add missing input parameters ******************arginNo=2;if (nargin < arginNo) scaleType = [];endarginNo = arginNo +1;if (nargin < arginNo) plotType = [];endarginNo = arginNo +1;if (nargin < arginNo) plotOpt = [];endarginNo = arginNo +1;% *************** Evalute the list extraParam of keywords ***************% These the value of this keywords are assigned to the local variables with% the same name as the keywords. The use of keywords is to make calls to% this function simpler.% *************** Pick out some fields from input parameters. ***************% ****************** Default values ******************if isempty(scaleType) scaleType = 'dB';end%ifif isempty(plotType) plotType = 'stairs';end%ifif isempty(plotOpt) plotOpt = '';end%if% ****************** Error check input parameters ******************chkdtype(scaleType, 'StringT')chkdtype(plotType, 'StringT')% ----------------------------------------------------------------------- %% Calculate the eigenvalues.% ----------------------------------------------------------------------- %eigVals = [];if iscell(corrMatIn) for n=1:length(corrMatIn) eigVals = [eigVals; getEigVals(corrMatIn{n})]; end%for nelse eigVals = getEigVals(corrMatIn);end%if iscell(corrMatIn)% ----------------------------------------------------------------------- %% Prepare the eigenvalues for plotting.% ----------------------------------------------------------------------- %% ****************** Scale types ******************if (strcmp(scaleType,'lin')) % Do nothing. ylabelTxt = '[lin]';elseif (strcmp(scaleType,'dB')) eigVals = 10*log10(eigVals+eps); ylabelTxt = '[dB]';else error('DBT-Error: Invalid scaleType.')end%ifxlabelTxt = '';% ----------------------------------------------------------------------- %% Plotting of the eigenvalues.% ----------------------------------------------------------------------- %if strcmp(plotType,'bar') % 'lin' here does not mean that the y-axis bar(eigVals,plotOpt)elseif strcmp(plotType,'barh') barh(eigVals,plotOpt) xlabelTxt = ylabelTxt; ylabelTxt = '';elseif strcmp(plotType,'bar3') bar3(eigVals,plotOpt) xlabelTxt = 'Eigenvalues'; ylabelTxt = '';elseif strcmp(plotType,'plot') plot(eigVals,plotOpt)elseif strcmp(plotType,'stem') stem(eigVals,plotOpt)elseif strcmp(plotType,'stairs') eigVals = [eigVals; eigVals(size(eigVals,1),:)]; stairs(eigVals,plotOpt) xmin(1)else error('DBT-Error: Unknown plot type.')end%iftitle('Eigenvalues')ylabel(ylabelTxt)xlabel(xlabelTxt)% ----------------------------------------------------------------------- %% Create output variable.% ----------------------------------------------------------------------- %if (nargout > 0) eigValsOut = eigValsend%if%endfunction eigplot1% ----------------------------------------------------------------------- %% Help function: Calculate the eigenvalues.% ----------------------------------------------------------------------- %function eigValsOut = getEigVals(corrMatStruct)% corrMat (RxCorrMatT, not cell array of RxCorrMatT): if (ndims(corrMatStruct.corrMat) ~= 2) error('Incorrect number of dimensions in correlation matrix.') end%if corrMatMx = corrMatStruct.corrMat(:,:,1,1,1,1,1,1); eigValsOut = []; sixeMx = sizem(corrMatMx); for n = 1: sixeMx(3) eigValsOut = [eigValsOut ; (flipud(sort(abs(eig(corrMatMx(:,:,n)))))).']; end%for n%endfunction getEigVals
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -