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

2 次查看(过去 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];

回答(1 个)

Babak
Babak 2013-4-10
Use MATLAB coder to convert matlab code into C code.
  2 个评论
Mohsin
Mohsin 2013-4-10
i have to convert only these lines i cant afford to purchase the MATLAB CODER
Jan
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by