Create a plot of a signal
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Miguel Albuquerque
el 5 de Jul. de 2022
Editada: Ishaan Mehta
el 12 de Jul. de 2022
Hey guys thanks in advance,
Basically I have this code, that for two signals( reference and surveillance) with 30 million samples each one, correlates them in doppler and delay.
But this correlation is very heavy, so I want to correlate a thousand samples individually , spaced between 3000 samples.
This means first I want to correlate reference_signal(1:1000) and surveillance_signal(1:1000), and save the plot. Next iteration, reference_signal(4000:5000) and surveillance_signal(4000:5000), and save the plot, and so on till the end of the samples.
Is there a way of doing this in MATLAB with a good matlab way?
nRef = numel(Reference_signal)/Fs;
nSurv = numel(Surveillance_signal)/Fs;
pulse_size = 500000;
for k = 1:nRef
Reference_signal_samples =Reference_signal((k-1)*pulse_size+(1:pulse_size));
for kk =1:nSurv
Surveillance_signal_samples=Surveillance_signal((kk-1)*pulse_size+(1:pulse_size));
[afmag3,delay3,doppler3] = ambgfun(Reference_signal_samples,Surveillance_signal_samples,Fs,[250000 250000]);
afmag3(afmag3>1 )= 1;
end
end
figure;
subplot(3,2,3)
surf(delay3,doppler3,afmag3,'LineStyle','-.');
shading interp;
axis([-0.5e-5 0.5e-5 -10000 10000]);
grid on;
view([140,35]);
colorbar;
xlabel('Doppler (Hz)');
ylabel('Ambiguity Function Magnitude');
title('Ambiguity Function Sref');
0 comentarios
Respuesta aceptada
Ishaan Mehta
el 6 de Jul. de 2022
Editada: Ishaan Mehta
el 12 de Jul. de 2022
Hey Miguel
I understand that you want to process a long array in batches while leaving out a fixed number of elements in between, and save the results of each iteration.
You can use MATLAB's reshape function to reshape the array into a form appropriate for your batching and spacing requirements, and use the saveas function to save the plot results if needed.
Below is a code snippet for your reference.
% dummy data for demo
Reference_signal_samples = (1:30000000) .* 1;
Surveillance_signal_samples = (1:30000000) + 0.1;
% reshaping according to the needed size and spacing
reference_reshaped = reshape(Reference_signal_samples, 1000, 4, []);
surveillance_reshaped = reshape(Surveillance_signal_samples, 1000, 4, []);
% printing some values for demo
reference_reshaped(:,1,1)
reference_reshaped(:,1,2)
reference_reshaped(:,1,3)
% looping through the entire array
sz = size(reference_reshaped)
for i = 1:sz(3)
% in every iteration, these variables will have 1000 samples
% skipping 3000 samples after the last iteration
r = reference_reshaped(:,1,i);
s = surveillance_reshaped(:,1,i);
% use r and s to do further processing and plotting
end
Hope it helps
Ishaan Mehta
2 comentarios
Ishaan Mehta
el 12 de Jul. de 2022
Editada: Ishaan Mehta
el 12 de Jul. de 2022
Hey Miguel
The for loop will process entire 30 million samples as per your requirements.
For 30 million samples, the loop will have 7500 iterations, one for each time you want to calculate correlation.
Since for each iteration, we use 1000 elements, and then skip the next 3000 elements, we are effectively processng 4000 elements per cycle.
Total cycles = 30 million / 4000 = 7500.
I have also updated the sample code in my answer to print the value of sz.
Hope this helps
Ishaan
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!