Clear Filters
Clear Filters

how do I extract the graph so that the x-axis becomes a frame

3 views (last 30 days)
1.present situation
Fig.0
Fig.1
Figure 0 is a numeric representation of the bin file. Based on the number of cells, we extracted the graph of Fig.1 by frame (code is below).
For example, suppose it's a 32 frame, we've written code to have 32 pictures like this. in other words, a graph with velocity information is drawn for each frame.
2. what I want
Fig.2
Like the graph in Figure 2., I want to show all the velocities of each frame in a single graph.
3. my code
What code should I add to represent the x-axis as a frame (time) as shown in Figure 2?
%% ADC data per frame
i = 0; % For recording the number of times
numframe = 32;
for n=1:numframe
A = adcData(1, (32768*(n-1)+1):numADCSamples*numChirps/numframe*n);
A = reshape(A, [numADCSamples, numChirps/numframe]); % column-numADCSample row-numChirps
% return receiver data % adcData FFT
radar_data_1dFFT = fftshift(fft(A,[], 2));%.*window_1D
fftSize1D = size(radar_data_1dFFT);
radar_data_2dFFT = fft(radar_data_1dFFT,[], 1);%.*window_2D
fft_out = radar_data_2dFFT;
%fft_out = fftshift(fft_out);
fft_out = 20*log10(abs(fft_out));
%% 횟수 기록
i = i+1;
%% Obtain range-velocity map after performing 2d fft
% range
c = 3e8; % speed of light
s = 29.9817e15; % slope of chirp signal
Fs = 7675e6;
fb = Fs/(numADCSamples-1)*(0:(numADCSamples-1)); % beat frequency
range = (c*fb)/(2*s);
% velocity
lamda = 5e-3; % Tx signal length
PRT = 310.8e-6; PRF = 1/PRT; % PRF = Pulse Repitition Frequency, PRT = ..Time
velocity = PRF/(numChirps/numframe-1)*(0:(numChirps/numframe-1))*lamda/4*pi;
% plot
figure; % two dimension
imagesc(-velocity, -range ,abs(fft_out));
xlabel('velocity(m/s)');ylabel('range(m)');
% save image
myfilename = sprintf('Going%d.png', i);
saveas(gcf, myfilename)
end

Answers (1)

Varun
Varun on 19 Apr 2023
Hello!
As per my understanding, you want to put together all the frames generated in the loop side-by-side in the same figure. Since, you are saving all the plots generated as image files (.png), you can use the imtile function to arrange the plots frame by frame. You can customise the grid size and other parameters to get the figure you need. You may find the documentation for ‘imtile’ at: https://www.mathworks.com/help/matlab/ref/imtile.html#mw_dcf93777-52b2-49db-a80e-c61ad515dd7b
Hope this helps!

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!