too many input arguments in my code!

2 views (last 30 days)
M. Omer Farooq
M. Omer Farooq on 23 Jul 2020
Commented: M. Omer Farooq on 24 Jul 2020
% input parameters
c = 3e8;
f0 = 24.005e9;
lambda = c/f0;
bw = 240e6;
fs=2*bw;
Rmax = 100;
tm = 5.5*range2time(Rmax,c);
fb=4.3636e+07;
%radar setup
waveform = phased.FMCWWaveform('SweepTime',tm,'SweepBandwidth',bw,...
'SampleRate',fs);
%target
tar_dist = 5;
tar_speed = 0;
tar_rcs = db2pow(min(10*log10(tar_dist)+5,20));
target = phased.RadarTarget('MeanRCS',tar_rcs,'PropagationSpeed',c,...
'OperatingFrequency',f0);
tarmotion = phased.Platform('InitialPosition',[tar_dist;0;0],...
'Velocity',[tar_speed;0;0]);
%environment
channel = phased.FreeSpace('PropagationSpeed',c,...
'OperatingFrequency',f0,'SampleRate',fs,'TwoWayPropagation',true);
antenna = patchMicrostrip('Length',75e-3, 'Width',37e-3,...
'GroundPlaneLength',120e-3, 'GroundPlaneWidth',120e-3);
%show(antenna)
ant_aperture = 0.002775; % in square meter
ant_gain = aperture2gain(ant_aperture,lambda); % in dB
tx_power = 0.85; % in watts
tx_gain = 9+ant_gain % in dB
rx_gain = 15+ant_gain; % in dB
rx_nf = 4.5; % in dB
transmitter = phased.Transmitter('PeakPower',tx_power,'Gain',tx_gain);
receiver = phased.ReceiverPreamp('Gain',rx_gain,'NoiseFigure',rx_nf,...
'SampleRate',fs);
radar_speed = 0;
radarmotion = phased.Platform('InitialPosition',[0;0;0],...
'Velocity',[radar_speed;0;0]);
%simulation%
rng(2012);
Nsweep = 64;
xr = complex(zeros(fix(waveform.SampleRate*waveform.SweepTime,Nsweep)));
for m = 1:Nsweep
% Update radar and target positions
[radar_pos,radar_vel] = radarmotion(waveform.SweepTime);
[tgt_pos,tgt_vel] = tarmotion(waveform.SweepTime);
% Transmit FMCW waveform
sig = waveform();
txsig = transmitter(sig);
% Propagate the signal and reflect off the target
txsig = channel(txsig,radar_pos,tgt_pos,radar_vel,tgt_vel);
txsig = target(txsig);
% Dechirp the received radar return
txsig = receiver(txsig);
dechirpsig = dechirp(txsig,sig);
end
Dn = fix(fs/(2*fb));
for m = size(xr,2):-1:1
xr_d(:,m) = decimate(xr(:,m),Dn,'FIR');
end
fs_d = fs/Dn;
fb_rng = rootmusic(pulsint(xr_d,'coherent'),1,fs_d);
rng_est = beat2range(fb_rng,sweep_slope,c)
i am getting these errors:
1. too many input arguments in : xr = complex(zeros(fix(waveform.SampleRate*waveform.SweepTime,Nsweep)));
2. Error using rootmusic,
Real signals require an even number p of complex sinusoids in: fb_rng = rootmusic(pulsint(xr_d,'coherent'),1,fs_d);
can anyone help?

Answers (1)

Steven Lord
Steven Lord on 23 Jul 2020
Edited: Steven Lord on 23 Jul 2020
For your first question, let's split out the innermost function call on that line of code.
xr = complex(zeros(fix(waveform.SampleRate*waveform.SweepTime,Nsweep)));
innermost = fix(waveform.SampleRate*waveform.SweepTime,Nsweep);
xr = complex(zeros(innermost));
The fix function only accepts one input argument. You're trying to pass two into it. I believe you just have a misplaced parenthesis.
xr = complex(zeros(fix(waveform.SampleRate*waveform.SweepTime),Nsweep));
% or splitting into pieces
innermost = fix(waveform.SampleRate*waveform.SweepTime);
middle = zeros(innermost,Nsweep);
xr = complex(middle);
  1 Comment
M. Omer Farooq
M. Omer Farooq on 24 Jul 2020
Thank you for you response.
can you explain the use of "fix" and how do we go without using it (as is in the original example: https://www.mathworks.com/help/phased/examples/automotive-adaptive-cruise-control-using-fmcw-technology.html)
and can you tell about rootmusic (error 2) too?
Thank you.

Sign in to comment.

Categories

Find more on Radar and EW Systems in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!