Borrar filtros
Borrar filtros

Plot data from txt file

18 visualizaciones (últimos 30 días)
Angel Lozada
Angel Lozada el 9 de Jun. de 2023
Comentada: Star Strider el 13 de Jun. de 2023
Hello.
I plotted a set of data (860000 samples) getting the followed plots:
Plot 1: Emitted Signal from NAA Station (Phase)
Plot 2: Emitted Signal from NAA Station (Amplitude)
The data were taking as 10 samples per second (see attached file named Figure 1), i.e., in second 0 the are 10 numbers, in second 1 another 10 numbers, and so on.
However, when I analyze the plots, is possible to see that there are more than 10 data (>>10 numbers) in 0s, the same for second 1 and so on.
I will appreciated your help.
Regards.
unzip('Data 2.zip'),movefile('Data 2.txt','10_03_2012_Modificado.txt')
clear;
data = readmatrix('10_03_2012_Modificado.txt');
T = data(:,1);
T = seconds(data(:,1));
T.Format = 'hh:mm';
T2 = data(:,2);
figure;
plot (T,T2,'x');
title 'Emitted Signal from NAA Station';
ylabel ('Phase');
xlabel ('Samples');
T = data(:,1);
T = seconds(data(:,1));
T.Format = 'hh:mm';
T3 = data(:,3);
figure;
plot (T,T3,'x');
title 'Emitted Signal from NAA Station';
ylabel ('Apmlitude');
xlabel ('Samples');
  2 comentarios
Star Strider
Star Strider el 10 de Jun. de 2023
I am not certain what you want to do.
The time vector appears to be consistent. The only detail that I can add is to combine the amplitude and phase data to create a complex signal and then plot the magnitude of the result —
Uzp = unzip('Data 2.zip');
A1 = readmatrix(Uzp{1})
A1 = 864000×3
0 -101.0300 23.5600 0.1000 -100.2100 23.8600 0.2000 -101.7000 23.5600 0.3000 -107.6600 23.4700 0.4000 -110.5400 22.7800 0.5000 -112.2900 21.6600 0.6000 -107.4600 21.6700 0.7000 -115.9300 21.2700 0.8000 -114.0500 22.2300 0.9000 -110.9900 22.2400
t = seconds(A1(:,1));
figure
yyaxis left
plot(t, A1(:,2))
ylabel('Phase (°)')
grid
yyaxis right
plot(t, A1(:,3))
ylabel('Amplitude')
xlabel('Time')
xlim([t(1) t(end)])
cs = A1(:,3) .* exp(1j*deg2rad(A1(:,2))); % Complex Signal
figure
plot(t, abs(cs))
grid
xlabel('Time')
ylabel('Magnitude')
xlim([t(1) t(end)])
I do not know what the result is supposed to look like, or what the data actaully represent.
.
Angel Lozada
Angel Lozada el 10 de Jun. de 2023
Dear Star Strider.
First at all, thanks for your soon reply and support.
I will try to explain in a better way my inquiry.
As you can see in previous attached .txt file there are 3 columns indicating a giving information for a signal.
Column 1: seconds and sample in each second; Column: 2 Phase and Column 3: Amplitude.
Let say we take a look to Phase data. In column 1 the collected data begin at 0s and during this time we have 10 samples (from 0.0 to 0.9), then at 1s we have other ten samples (1.0 to 1.9), and so on.
Attached file Figure 3 shows the expected plot (plotting 10 samples in each second) and also shows what I am getting in current Phase plot (a lot of samples between second 0 and 1). You can see in this Figure 3 that is a kind of discrete plot, because there is information (samples) only in each second and not in between.
Again, thanks for your support and patience.
Regards.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 10 de Jun. de 2023
If you simply want to aggregate the data in each second and plot them that way, try something like this —
Uzp = unzip('Data 2.zip');
A1 = readmatrix(Uzp{1})
A1 = 864000×3
0 -101.0300 23.5600 0.1000 -100.2100 23.8600 0.2000 -101.7000 23.5600 0.3000 -107.6600 23.4700 0.4000 -110.5400 22.7800 0.5000 -112.2900 21.6600 0.6000 -107.4600 21.6700 0.7000 -115.9300 21.2700 0.8000 -114.0500 22.2300 0.9000 -110.9900 22.2400
t = seconds(A1(:,1));
ixv = ceil(A1(:,1) + 1E-12); % Index Vector For 'accumarray'
secv = accumarray(ixv, (1:size(A1,1)).', [], @(x){A1(x,[2 3])}) % Aggregatte Points By Second
secv = 86400×1 cell array
{10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double} {10×2 double}
A2 = reshape(cell2mat(secv).', 2,10,[]); % Convert To Numeric MAtrix From Cell Array & Reshape ARray
tv = unique(ixv); % Corresponding Time Vector
figure
yyaxis left
plot(tv, squeeze(A2(1,:,tv)), '.')
ylabel('Phase (°)')
grid
yyaxis right
plot(tv, squeeze(A2(2,:,tv)), '.')
ylabel('Amplitude')
xlabel('Time')
% xlim([tv(1) tv(end)])
xlim([0 5.5])
% cs = A2(2,:,:) .* exp(1j*deg2rad(A2(1,:,:))); % Complex Signal
%
% figure
% plot(tv, squeeze(abs(cs)))
% grid
% xlabel('Time')
% ylabel('Magnitude')
% % xlim([0 5.5])
% xlim([tv(1) tv(end)])
This plots them as dots rather than asterisks. Choose whatever marker you want.
.
  2 comentarios
Angel Lozada
Angel Lozada el 13 de Jun. de 2023
Star Strider.
Thanks for your cooperation.
I appreciated.
Star Strider
Star Strider el 13 de Jun. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by