Plot data from txt file
5 ビュー (過去 30 日間)
表示 古いコメント
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');
採用された回答
Star Strider
2023 年 6 月 10 日
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!