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

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일

0 개 추천

Use MATLAB coder to convert matlab code into C code.

댓글 수: 2

i have to convert only these lines i cant afford to purchase the MATLAB CODER
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?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2013년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by