I want to know how to convert these lines of code into c

5 views (last 30 days)
fs = 70e6; % sampling frequency
b = 25e6; % bandwidth
trans_freq = 9.375e9; % Carrier frequency
sweep_time = 1e-3; % sweep time
total_sweeps = 4;
t=0:1/fs:sweep_time; % sweep time matrix
c = 3e8;
range = 24000;
velocity = 50; % velocity in m/s
fd = (2*trans_freq*velocity)/c;
% fd = 0;
td2 = 2*range/c; % delay in seconds
fb = (2*b*range)/(sweep_time*c);
td = round((2*range/c)*fs); % delay in number of samples w.r.to range
beat = sin(2*pi*fd*t);
z = zeros(1,td);
for i = 1:total_sweeps;
if(mod(i,2)== 0)
tx_dn=chirp(t,b,sweep_time,0);
tx((sweep_time*fs*(i-1)+i):sweep_time*fs*i+i) = tx_dn;
rx_dn=chirp(t,b+fd,sweep_time,0+fd);
rx((sweep_time*fs*(i-1)+i):sweep_time*fs*i+i) = rx_dn;
% rx((sweep_time*fs*(i-1)+i):sweep_time*fs*i+i) = rx_dn;
rx_4mix(i,:) = [z rx_dn];
tx_4mix(i,:) = [tx_dn z];
else
tx_up=chirp(t,0,sweep_time,b);% Start @ DC, cross 25MHz at t=3 millisec
tx((sweep_time*fs*(i-1)+i):sweep_time*fs*i+i) = tx_up;
rx_up=chirp(t,0+fd,sweep_time,b+fd);% Start @ DC+fd, cross 25MHz at t=3 millisec
rx((sweep_time*fs*(i-1)+i):sweep_time*fs*i+i) = rx_up;
% rx((sweep_time*fs*(i-1)+i):sweep_time*fs*i+i) = rx_up;
rx_4mix(i,:) = [z rx_up];
tx_4mix(i,:) = [tx_up z];
end
end
rx = [z rx];

Answers (1)

Babak
Babak on 10 Apr 2013
Use MATLAB coder to convert matlab code into C code.
  2 Comments
Mohsin
Mohsin on 10 Apr 2013
i have to convert only these lines i cant afford to purchase the MATLAB CODER
Jan
Jan on 11 Apr 2013
This is obviously not trivial. Commands like chirp require a lot of work and even 0:1/fs:sweep_time is not trivial.
I assume a professional C programmer can convert this in 40 hours. But as usual for programming projects, the doubled time is realistic also.
Why do you want to convert this to C?

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!