Plot data from txt file
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Angel Lozada
il 9 Giu 2023
Commentato: Star Strider
il 13 Giu 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 Commenti
Star Strider
il 10 Giu 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})
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.
.
Risposta accettata
Star Strider
il 10 Giu 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})
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
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!