Range Simulation for a Portable radar
이전 댓글 표시
I'm trying to simulate Range with the following scrip but is giving me the following error:
Index exceeds matrix dimensions.
Error in RangeSimulation (line 35) [Y1,I1] = max(abs(spec(Fs/2+2:Fs+1)));
Need help. Here is the code:
clc; clear all; format long e;
% Declare constants
Fs = 40000; % Sampling freruency
T = 1/Fs; % Period
osf = 100;
T0 = 100e-6;
t = (0:T/osf:T0);
w = 2 * pi * 2.4e9; % Angular frequency
fm = 50; df = 330e6;
alpha = .1;
d = 4; % Target distance in m
c = 3e8;
delay = 2 * d / c;
lambda = c / (w / 2 / pi);
dr = c / 2 / df; % Range resolution
% Calculate range r = 2*pi*df * sawtooth(2*pi*fm*t,0.5); % r = 2*pi*df * sawtooth(2*pi*fm*t,1); Tx = cos((w+r).*t); Yx = alpha * cos((w+r).*(t-delay)); %Rx = awgn(Yx,3); % Add white Gaussian noise Rx = Yx; Sx = Tx .* Rx; tay = taylorwin(length(Sx)); %tay = hamming(length(Sx)); A = tay .* Sx'; X = fftshift(fft(A)); spec = fftshift(fft(Sx)); f = (-Fs/2:1/T0/osf:Fs/2);
% Calculate weighted-mean beat frequency %fb1 = abs(spec(Fs/2+2:Fs+1))*f(Fs/2+2:Fs+1)'; %fb = fb1 / Fs / 2; [Y1,I1] = max(abs(spec(Fs/2+2:Fs+1))); [Y2,I2] = max(abs(X(Fs/(2+2):Fs+1))); fb1 = f(Fs/2+I1); fb2 = f(Fs/2+I2);
% Plot the figure subplot(3,1,1); plot(f,abs(spec)/Y1); title('No windowing'); title('Normalized Spectrum of Mixed Signal w/ Stationary Target (R = 2 m)'); xlabel('Frequency (Hz)'); ylabel('Magnitude'); % subplot(3,1,1); plot(t,Tx); % subplot(3,1,2); plot(t,Rx); % subplot(3,1,3); plot(t,Sx); subplot(3,1,2); plot(f,abs(X)/Y2); title('With windowing'); R1 = c * fb1 / 8 / df / fm; R2 = c * fb2 / 8 / df / fm; subplot(3,1,3); title('Difference in FFTs'); plot(f,(abs(X)'/Y1)-(abs(spec)/Y1)); a1 = mean(abs(A)); a2 = mean(abs(Sx));
댓글 수: 2
Walter Roberson
2012년 5월 26일
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Image Analyst
2012년 5월 26일
Edit. Highlight your code. Click the "Code" icon. Resubmit.
Run it again, with the debugger, to see what the size of all the variables is. Make intermediate variables if you have to, like
sf = spec(Fs/2+2:Fs+1)
size_of_sf = size(sf)
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Radar and EW Systems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!