what is the error code?
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
error code is 'All training cells must lie inside the rectangular region defined by X' however, i don't know this mean.
how do i fix it??
clear;
close all;
clc;
R1 = 20; %[m]
v1 = 15; %[m/s]
R2 = 23; %[m]
v2 = 20; %[m/s]
R3 = 15;
v3 = 10;
fc = 77e9; %[Hz]
c = 3e8; %[m/s]
BW = 300e6; %[Hz]
T = 10e-6; %[sec]
fs = 5e6; %[Hz]
Ts = (1/fs); %[sec]
Td = (2*R1)/c; %[sec]
K = BW/T; %모듈 상수
fd1 = (2*v1*fc)/c; %[Hz]
fd2 = (2*v2*fc)/c; %[Hz]
fd3 = (2*v2*fc)/c;
lambda = c/fc;
Tf = T*256;
theta = [30, -45, 15];
d = lambda/2;%[m]
num_ant = 128;
%d1 2d-fft
x = zeros(num_ant,1);
Nn = 512;
Np = 256;
d1 = zeros(num_ant, Nn, Np);
for k=1:num_ant
for n=1:Nn
for p=1:Np
d1(k,n,p) = 10*exp(1i*2*pi*(((2*K*R1)/c+ fd1)*(n*Ts) + fd1*p*T + (2*fc*R1)/c))*exp(1i*(2*pi/lambda)*d*(k-1)*sin(theta(1,1)*pi/180))...
+ 5*exp(1i*2*pi*(((2*K*R2)/c+ fd2)*(n*Ts) + fd2*p*T + (2*fc*R2)/c))*exp(1i*(2*pi/lambda)*d*(k-1)*sin(theta(1, 2)*pi/180))...
+ 1*exp(1i*2*pi*(((2*K*R3)/c+ fd3)*(n*Ts) + fd3*p*T + (2*fc*R3)/c))*exp(1i*(2*pi/lambda)*d*(k-1)*sin(theta(1, 2)*pi/180));
end
end
end
d1 = awgn(d1, 10, 'measured');
signal1 = abs(fft2(squeeze(d1(1, :, :))));
signal2 = abs(fft2(squeeze(d1(:,1,:))));
signal3 = abs(fft2(squeeze(d1(:,:,1))));
signal1 = fftshift(signal1, 2);
signal2 = fftshift(fftshift(signal2, 1), 2);
signal3 = fftshift(signal3, 1);
cfar2D = phased.CFARDetector2D('GuardBandSize',5,'TrainingBandSize',10 ,...
'ProbabilityFalseAlarm',1e-5);
hrdresp = phased.RangeDopplerResponse(...
'DopplerFFTLengthSource','Property',...
'DopplerFFTLength',1024,...
'SampleRate',fs);
[resp,rng_grid,dop_grid] = step(hrdresp,abs(fft2(squeeze(d1(1, :, :)))),[1;1]);
rs = RandStream('mt19937ar','Seed',5);
npow = db2mag(20);
resp = resp + npow/sqrt(2)*(randn(rs,size(resp)) + 1i*randn(rs,size(resp)));
resp = abs(resp).^2;
[~,rangeIndx] = min(abs(rng_grid-[0 40]));
[~,dopplerIndx] = min(abs(dop_grid-[-30 30]));
[columnInds,rowInds] = meshgrid(dopplerIndx(1):dopplerIndx(2),...
rangeIndx(1):rangeIndx(2));
CUTIdx = [rowInds(:) columnInds(:)]';
detections = cfar2D(resp,CUTIdx);
figure
detectionMap = zeros(size(resp));
detectionMap(rangeIndx(1):rangeIndx(2),dopplerIndx(1):dopplerIndx(2)) = ...
reshape(double(detections),rangeIndx(2)-rangeIndx(1)+1,dopplerIndx(2)-dopplerIndx(1)+1);
h = imagesc(dop_grid/128,rng_grid/512,detectionMap);
xlabel('Doppler (Hz)'); ylabel('Range (m)'); title('Range Doppler CFAR Detections');
h.Parent.YDir = 'normal';
0 Kommentare
Antworten (1)
Vidip
am 2 Nov. 2023
I understand that the error you encountered, "All training cells must lie inside the rectangular region defined by X," typically occurs when using the Constant False Alarm Rate (CFAR) detector in MATLAB's Phased Array System Toolbox.
This can happen if you have set the ‘GuardBandSize’ or ‘TrainingBandSize’ properties to be too large. To fix this error, you can either increase the size of the range-Doppler map or decrease the size of the guard band and training band.
For further information, refer to the documentation link below:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Detection finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!