📄 simwidebandkernel.m
字号:
if isempty(propSpeed) propSpeed = speedoflight;end%ifif isempty(srcType) srcType = 'randn';end%ifif isempty(srcSignals) if (strcmp(srcType,'det')) srcSignals = ones(1,noTime); else srcSignals = []; end%ifend%ifif isempty(srcPowers) srcPowers = 1;end%ifif isempty(srcDoas) srcDoas = d2r([0;0]);end%ifif isempty(srcRanges) srcRanges = 1000;end%ifif isempty(notUsed) notUsed = [];end%ifif isempty(srcCorr) srcCorr = {[]};end%ifif isempty(noiseType) noiseType = 'nonoise';end%ifif isempty(noisePower) noisePower = 1;end%ifif isempty(noiseCorr) noiseCorr = {[]};end%ifif isempty(orthSig) orthSig = 0;end%ifif isempty(corrMethod) corrMethod = 0;end%ifif isempty(corrMethod) testParam = [];end%if% ************* Pick out some fields from input parameters. *************noSrc = size(srcDoas,2); % Number of sources signals.noChan = antenna.noElem ; % Number of antenna channels.%if (iscell(bandwidth))% freqLow = carrierFreq + bandwidth{1};% freqHigh = carrierFreq + bandwidth{2};%else% freqLow = carrierFreq - bandwidth/2;% freqHigh = carrierFreq + bandwidth/2;%end%if%freq = linspace(freqLow, freqHigh, noFreq+1);%freq = freq(1:noFreq);% This code is now handled by the function "genfreqaxis".srcCorrSrc = srcCorr{1}; % The correlation between different signal sources.noiseCorrSrc = noiseCorr{1}; % The correlation of the noise between different antenna channels.% ****************** Error check input parameters ******************% These tests can be removed without affecting the operation of this function.chkdtype(srcType, 'StringT')chkdtype(antenna, 'AntDefT')chkdtype(carrierFreq, 'RealScalarT')chkdtype(bandwidth, 'RealScalarT', 'CellArrayT')chkdtype(noTime, 'IntScalarT')chkdtype(noTrials, 'IntScalarT')chkdtype(srcSignals, 'CxMatrixT')chkdtype(srcDoas, 'Vector of DoaT')chkdtype(srcPowers, 'RealVectorT')chkdtype(srcCorr, 'CxMatrixT')chkdtype(orthSig, 'IntScalarT')chkdtype(propSpeed, 'RealVectorT')chkdtype(corrMethod, 'IntScalarT')chkdtype(noiseType, 'StringT')chkdtype(noisePower, 'RealVectorT')chkdtype(noiseCorr, 'CxMatrixT')% ----------------------------------------------------------------------- %% Simulation of source signals.% ----------------------------------------------------------------------- % % sourceSigTime (CxMatrixT): Complex envelope of the simulated source % signals in the time domain in a (noSrc, noTime) complex matrix. % ****************** Deterministic Signals. ****************** if (strcmp(srcType,'det')) sourceSigTime = srcSignals; % Use the signals given by the input parameter "srcSignals". noTime = size(sourceSigTime,2); % Over-ride the setting of the input parameter "noTime". % ****************** Gaussian stochastic signals. ****************** elseif (strcmp(srcType,'randn')) %[U,S,V] = svd(srcCorrSrc); %B=(1/sqrt(2))*U*sqrt(S); % Compute the square root of the source covariance matrix with SVD. %sourceSigTime = B*(randn(noSrc,noTime) + j*randn(noSrc,noTime)) sourceSigTime = (randn(noSrc,noTime) + j*randn(noSrc,noTime)) / sqrt(2); % The variance for the real and imaginary parts are 1. % The total variance of the signal is therefore 1+1=2. % The signal power is equal to the variance when, as here, % the mean value is 0. This is the reason for the normalisation % (of the amplitude) with the square root of the power % ************* Uniformly distributed stochastic signals. ************* elseif (strcmp(srcType,'rand')) % NOTE: This implementation is not finnished. The power is not yet % normalized. sourceSigTime = (rand(noSrc,noTime) + j*rand(noSrc,noTime)); % ****************** No source signals. ****************** elseif (strcmp(srcType,'nosrc')) sourceSigTime = 0; % ****************** The else branch. ****************** else error('DBT-Error: Specified signal type is not implemented.') end%if% ----------------------------------------------------------------------- %% Simulation of noise signals.% ----------------------------------------------------------------------- % % ****************** Gaussian stochastic signals. ****************** if (strcmp(noiseType,'randn') | strcmp(noiseType,'Gaussian')) noiseSigTime = (randn(noChan,noTime) + j*randn(noChan,noTime)) ... * 1/sqrt(2) * sqrt(noisePower); % First, generate i.i.d random variables with variance (power) two. % The total power of the simulatred noise from "randn" % is 1 + 1 (real + imaginary) = 2. % The factor 1/sqrt(2) normalizes the simulated noise to 1. % The last factor, sqrt(noisePower), gives the noise the desired power. % ****************** No noise signals. ****************** elseif (strcmp(noiseType,'nonoise')) noiseSigTime=0; % ****************** The else branch. ****************** else error('DBT-Error: The noise model does not exist.') end%if% ----------------------------------------------------------------------- %% Orthogonalization of the source and noise signals.%% NOTE: The implementation of these operations is not finnished.% ----------------------------------------------------------------------- %% ************** Orthogonalization of the source signals. **************% Should also the noise signal be orthogonalized simultaneously?if (orthSig) Rrand=sourceSigTime*sourceSigTime'/noTime; sourceSigTime=sqrtm(inv(Rrand))*sourceSigTime; % ortonormala vektorer. % The signal vectors (row vectors) are now orthogonal to eachother. % CHECK THIS !?! AS FA?end%if% ************** Orthogonalization of the noise signals. ************** % Maybe it is better to do the orthogonalization together with the % source signals so that source and noise signal become orthogonal to % eachother. LP did it that way. Or is it a good idea to be able to choose? if (orthSig) noiseSigTime = noiseSigTime; end%if if (~isempty(noiseCorrSrc) ) % Color the noise spatially with the spatial noise correlation matrix. [U,SIG,V] = svd(noiseCorrSrc); noiseSigTime = U*sqrt(SIG)*noiseSigTime; % Compute the square root of the source covariance matrix with SVD. % Color the i.i.d random variables with the square root of the % noise covariance matrix. end%if% ----------------------------------------------------------------------- %% Correlate the source signals and adjust the power level.%% ----------------------------------------------------------------------- %% ************** Scale the source signals to the right power. **************estPower = mean(abs(sourceSigTime).^2 ,2); % estPower (RaelVectorT) (noSrc x 1): Estimate the power in the % source signals.scaleFactors = sqrt(srcPowers) ./ estPower;sourceSigTime = weightrows(sourceSigTime, scaleFactors); %WEIGHTROWS: A DBT function that weights the rows of a matrix. The same % weight is applied to all columns of the same row. This is equal to % Y = diag(weights)*X .% ************** Correlate the source signals. **************if (~isempty(srcCorrSrc)) if (corrMethod == 0) % Lars Pettersson's version. sourceSigTime=sqrtm(srcCorrSrc)*sourceSigTime; else [U,S,V] = svd(srcCorrSrc); B=(1/sqrt(2))*U*sqrt(S); % Compute the square root of the source covariance matrix with SVD. % Is there any advantage with this method? sourceSigTime = B*sourceSigTime; end%ifend%if% ----------------------------------------------------------------------- %% Correlate the noise signals and adjust the power level.%% ----------------------------------------------------------------------- %% ************** Scale the noise signals to the right power. **************% ************** Correlate the noise signals. **************% ----------------------------------------------------------------------- %% Time shift, according to element positions, and scale the source signals.%% This is the influence of the array antenna on the source sign.als.% Start: 981211 Svante Bj鰎klund (svabj).% ----------------------------------------------------------------------- %focusDist = []; % Focusing distance for the spatial steering matrix. % [] = default value. See the help text for % the function "spastemat".subPointDoa = []; % Pointing directions for possible subarrays. % [] = default value. See the help text for % the function "spastemat".noFreq = noTime; % Number of frequency points for the signals.chanSigFreq = zeros(noChan,noTime); % Signals X in the antenna channels. % sourceSigTime (CxMatrixT): Complex source time signals (the complex % envelopes) S in a (noTime, noSrc)-matrix. % chanSigFreq (CxMatrixT): Complex signals (the complex envelopes) X of % the antenna channels in a (noOfChannels, noFreq)-matrix.sourceSigFreq = fftshift1(fft(sourceSigTime.')).'; % To the frequency domain. % FFTSHIFT1: A DBT function that shifts DC component to center of spectrum % for several 1D spektra or shifts the DC component from the center. % sourceSigFreq (CxMatrixT): Complex source time signals (the complex % envelopes) S in a (noSrc, noFreq)-matrix.[freq, freqLow, freqHigh] = genfreqaxis(carrierFreq, bandwidth, noFreq);lambda = propSpeed./freq;for freqLoop = 1:noFreq A = spastemat(antenna,srcDoas,lambda(freqLoop),focusDist,subPointDoa); % A DBT function that calculates the spatial steering matrix. chanSigFreq(:,freqLoop) = A * sourceSigFreq(:,freqLoop);end%for freqLoopchanSigTime = ifft(fftshift1(chanSigFreq.','inv')).'; % Back to time domain. % chanSigFreq (CxMatrixT): Complex signals (the complex envelopes) X of % the antenna channels in a (noOfChannels, noTime)-matrix.% ----------------------------------------------------------------------- %% Add noise and source signals.% ----------------------------------------------------------------------- %%estSignalPower = mean(abs(chanSigTime).^2 ,2).' % For debugging.%estNoisePower = mean(abs(noiseSigTime).^2 ,2).' % For debugging.%estSNRdB = 10*log10(estSignalPower./estNoisePower) % For debugging.chanSigTime = chanSigTime + noiseSigTime;% ----------------------------------------------------------------------- %% Create output signal variable.%% This section creates a standard DBT signal of data type RxRadarSigT.% ----------------------------------------------------------------------- %carrierWavelength = propSpeed / carrierFreq;noRangeBins = 1;pModulation = []; % Should this parameter be assigned "sourceSigTime" ?sampleTime = 1/(freqHigh-freqLow); % sampleTime (RealScalarT): Stored in the output signal "sigOut" for % possible use in signal processing routines.noCPI = 1;signals = zerosm([noTime, noRangeBins, noChan, 1, noCPI]);signals = setm(signals, chanSigTime.', ':',1,':',1,1); % SETM is a RECVAR function deliverad with DBT. It can be replaced with % standard Matlab 5 multidimensional array indexing.waveform = defwave(carrierWavelength, noRangeBins, noTime, pModulation, ... sampleTime, noCPI); % DEFWAVE is a DBT function, with the help of which the time properties % of a radar or radio signal can be specified.sigOut = RxRadarSigT(signals,{antenna, waveform});%endfunction simwidebandkernel%End Of File -------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -