disp('NoviablePRF');
disp(['MinimumPRF(DopplerBWconstraint)=',num2str(BWdopp)]);
disp(['MaximumPRF=(Swathambiguityconstraint)=',...
num2str(2*Ls/c)]);
disp('')
return
end
end
oversample_st=PRF/BWdopp;
PRI=(1/PRF); %PRIinsec
%computenumberofpulses,aperturepositions
Npulses=round(Ta/PRI); %#ofpulses
jkl=0:
(Npulses-1); %pulseindexarray
T_0=PRI*jkl; %relativestarttimesofpulses,insec
T_0=T_0-max(T_0)/2; %recenterspulsetimessymmetrically+/-aroundzero
u=v*T_0; %aperturepositions
%formradarchirppulse
W=c/2/DR; %chirpbandwidth,Hz
fs=oversample_ft*W; %chirpsamplingrate,Hz
s=git_chirp(tau,W,fs/W);
Ns=length(s);
fprintf('\nPulselength=%gmicroseconds\n',tau/1e-6)
fprintf('Chirpbandwidth=%gMhz\n',W/1e6)
fprintf('Time-bandwidthproduct=%g\n',W*tau)
fprintf('Fasttimesamplingrate=%gMsamples/sec\n',fs/1e6)
figure
(1)
plot((1e6/fs)*(0:
length(s)-1),[real(s)imag(s)])
title('RealandImaginaryPartsofChirpPulse')
xlabel('time(usec)')
ylabel('amplitude')
grid
fprintf('\nWearesimulating%gpulsesatanRFof%gGHz',Npulses,fc/1e9)
fprintf('\nandaPRFof%gkHz,givingaPRIof%gusec.\n\n',PRF/1e3,PRI/1e-6)
Ntargets=size(coords,1);
fprintf('\nThereare%gtargetswiththefollowinglocationsrelativetotheCRP:
',Ntargets)
fornt=1:
Ntargets
fprintf('\n x=%+8.1fm,R=%+8.1fm',coords(nt,1),coords(nt,2));
end
fprintf('\n\n')
%Precomputerangevs.pulsenumber. Radarcoordinatesgivenbyx=u,r=0;
%targetcoordinatesrelativetotheCRPareinarray'coords'.
range=zeros(Ntargets,Npulses);
fornt=1:
Ntargets
form=1:
Npulses
%我今天在这个问题上纠结了整整一天,原因是没看出来散射点都在阴影部分的X-O-Yg平面上,Rcrp是椭圆长条的中心啊
range(nt,m)=sqrt((coords(nt,1)-u(m))^2+ (Rcrp+coords(nt,2))^2);
%以上生成SAR数据的操作其实就是模型变换的过程,将模型坐标系中的坐标点转换到全局坐标系下的坐标
%我以前不知道Rcrp就是Rp,类似于到坐标原点,coords(nt,1)-u(m)是x轴方向上P点到x=u这条线的距离
%Rcrp加上coords(nt,2)的效果就是相对于yg轴偏移coords(nt,2)
end
end
figure
(2)
plot(u,range)
xlabel('apertureposition(m)')
ylabel('range(m)')
title('Rangevs.AperturePositionforeachScatterer')
grid
Rmin=min(min(range));
Rmax=max(max(range));
%checktoseeifminandmaxrangefallinthedefinedswath
if((RminRcrp+Ls/2)) %Rcrp就是swath椭圆长条的中心啊
disp('Targetrangesoutsideofswath!
')
disp(['Swathlimitsare',num2str(Rcrp-Ls/2),'to',num2str(Rcrp+Ls/2)])
disp(['Minandmaxrangeare',num2str(Rmin),'and',num2str(Rmax)])
return
end
%Definetherangewindow
T_out=[2*(Rcrp-Ls/2)/c,2*(Rcrp+Ls/2)/c+tau]; %时间窗对应的距离窗
fprintf('\nTherangewindowlimitsare%gto%gusec.\n',...
T_out
(1)/1e-6,T_out
(2)/1e-6)
fprintf('\nTherangewindowstartsat%gkm.',(Rcrp-Ls/2)/1e3)
fprintf('\nTherangewindowendsat%gkm.',(Rcrp+Ls/2)/1e3)
fprintf('\nTheunambiguousrangeintervalis%gkm.\n\n',c/2/PRF/1e3)
%Nowbuildthefasttime/slowtimedatamatrix
disp('Nowformingsignalmatrix')
delta_t=1/fs; %samplinginterval(sec)
t_y=[T_out
(1):
delta_t:
T_out
(2)]'; %outputsamplingtimes(sec)
T_p=Ns*delta_t; %lengthofinputpulse(sec)
%ensurethatallvectorsarecolumnvectors
s=s(:
); T_0=T_0(:
);
%determinethequadraticphasemodulationparametersfor
%laterinterpolationofpulsesamples
t_s=delta_t*[0:
(Ns-1)]';
s_ph=unwrap(angle(s)); %s是线性调频chirp信号
warningoffMATLAB:
polyfit:
RepeatedPointsOrRescale %killsanannoyingMATLABwarningabout
%thepolyfitfunction
q=polyfit(t_s,s_ph,2); %2次多项式拟合chirp信号的相位
%checkresultusingcorrelationcoefficient
sfit=polyval(q,t_s); %sfit与s_ph应该接近
if(s_ph'*sfit)/norm(s_ph)/norm(sfit)<0.99 %相关系数是这样算的,我以前不会啊!
disp('pulsephaseisnotlinearorquadratic')
disp('')
return
end
%
%--- Form(initiallyempty)outputmatrix---
%
Nr=length(t_y); %outputsamplesinamatrix
y=zeros(Nr,Npulses); %Nr是快时间维度也叫距离维,Npulses是慢时间维度也叫多普勒维,横向距离维度
form=1:
Npulses %loopoveraperturepositions
if(mod(m,100)==1)
disp([' ...processingpulse#',int2str(m),'of',int2str(Npulses)])
end
forn=1:
Ntargets %loopovertargets
r=range(n,m);
%Computestartandendtimeofreflectedpulseatreceiver,
%ensurethatitfallsentirelywithintherange(time)window
tmin=2*r/c;tmax=tmin+T_p; %T_p是脉冲宽度,tmin和tmax原来是时间观察窗口,即“时间窗”
if((tmin(1))|(tmax>T_out
(2)))
fprintf('\nEchofromtarget#%gatrange%gkm',n,r/1e3) %r是距离窗
fprintf('\nisCOMPLETELYOUTOFtherangewindow')
fprintf('\nonpulse#%g.\n',m)
return
end
%Figureoutwhichsamplelocationsintheoutputgridcontain
%reflectedpulse
t_vals=t_y-tmin; %t_y是快时间
n_out=find(t_vals>=0 & t_vals
%Placepulseintooutputmatrix.
% Stop-and-hopassumed,soonlyphasemodulationisduetogeometry.
%Allpulseshaveunitamplitude.
%ThereisnoadjustmentforR^4,either.
y(n_out,m)=y(n_out,m)+...
exp(-j*2*pi*fc*tmin)... %fc是载频,tmin在这里用,我以前不知道啊,tmin相当于一个时间起点
.*exp(j*polyval(q,t_vals(n_out)));
end %endofloopovertargets
end %endofloopoverpulses
figure(3)
imagesc(1:
Npulses,t_y,real(y))
xlabel('pulsenumber')
ylabel('fasttime(sec)')
title('RealPartofDataMatrix')
%Savethedatamatrixinspecifiedfile.
%Savethestudentversioninthemysteryfile.
%Alsosaveallparametervaluedisplaysincorrespondingfile
data_file=[file,'.mat'];
mystery_file=[file,'_mys.mat'];
listing_file=[file,'.lis'];
eval(['save',data_file,'ctauWfssNpulsesPRFPRIT_outfc',...
'TavlambdaRcuRcrpLsDRDCRNtargetscoordsyt_yNr']);
eval(['save',mystery_file,'ctauWfssNpulsesPRFPRIT_outfc',...
'TavlambdaRcuRcrpLsDRDCRyt_yNr']);
fid=fopen(listing_file,'w'); %listingfile
fprintf(fid,['\rDESCRIPTIONOFDATAINFILE',file,'.matAND',file,'_mys.mat\r\r']);
fprintf(fid,'\nRangeresolution=%gmeters',DR);
fprintf(fid,'\nCross-rangeresolution=%gmeters',DCR);
fprintf(fid,'\nRangetocentralreferencepoint=%gkm',Rcrp/1e3);
fprintf(fid,'\nAperturetime=%gseconds',Ta);
fprintf(fid,'\nRangecurvatureatCRP=%gmeters\n\n',Rc);
fprintf(fid,'\rPulselength=%gmicroseconds\r',tau/1e-6);
fprintf(fid,'\rChirpbandwidth=%gMhz\r',W/1e6);
fprintf(fid,'Time-bandwidthproduct=%g\n',W*tau);
fprintf(fid,'\rWearesimulating%gpulsesatanRFof%gGHz',Npulses,fc/1e9);
fprintf(fid,'\r andaPRFof%gkHz,givingaPRIof%gusec.',PRF/1e3,PRI/1e-6);
fprintf(fid,'\nRangeresolution=%gmeters',DR);
fprintf(fid,'\nCross-rangeresolution=%gmeters',DCR);