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];
댓글 수: 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?
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!