I want to know how to convert these lines of code into c
1 次查看(过去 30 天)
显示 更早的评论
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];
0 个评论
回答(1 个)
Babak
2013-4-10
Use MATLAB coder to convert matlab code into C code.
2 个评论
Jan
2013-4-11
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?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!