Matlab sensing the dynamic data changes and automatically plotting
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello guys,
This is my plot. In the plot, you can see 6 periods where big dynamic data changes happened. I don't want an overall normal conventional plot.
I want the Matlab to sense these 6 periods and generate 6 plots.
load = 'newdata3.csv';
data = readtable(load);
data = sortrows(data,'Var1','ascend');
timetable(data.Var1, data.Var2);
plot(data.Var1,data.Var2)
j1 = find(diff([0; data.Var2]) > 10);
ss = data(j1,:);
plot(ss.Var1,ss.Var2)
This is the plot I got after using your code. But I want to generate 6 plots. Can you help me?
0 Commenti
Risposta accettata
Star Strider
il 2 Nov 2022
Just the code this time —
data = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1175778/newdata3.csv');
data.Var1.Format = 'HH:mm:ss.SSS'
TS = sortrows(data,1);
TS.Var1 = TS.Var1 + 0.001*seconds(0:size(TS,1)-1).';
[envh,envl] = envelope(TS.Var2, 130, 'peaks');
% figure
% plot(TS{:,1}, TS{:,2})
% grid
% xlabel('x')
% ylabel('y')
% xline(TS.Var1(1,1)+seconds(0:60:3600))
% xline(TS.Var1(1,1)+seconds(0:300:3600),'-r', 'LineWidth',2)
figure
plot(TS{:,1}, TS{:,2}, 'DisplayName','Data')
hold on
plot(TS{:,1}, envh, '-r', 'DisplayName','Upper Envelope')
plot(TS{:,1}, envl, '-g', 'DisplayName','Lower Envelope')
hold off
grid
xlabel('x')
ylabel('y')
legend('Location','best')
figure
plot(TS{:,1}, TS{:,2}, 'DisplayName','Data')
hold on
plot(TS{:,1}, envh, '-r', 'DisplayName','Upper Envelope')
plot(TS{:,1}, envl, '-g', 'DisplayName','Lower Envelope')
grid
xlabel('x')
ylabel('y')
legend('Location','best')
% xline(TS.Var1(1,1)+seconds(0:60:3600))
% xline(TS.Var1(1,1)+seconds(0:300:3600),'-r', 'LineWidth',2)
xlim([TS.Var1(1,1) TS.Var1(9600,1)])
Lv = envh > 30 & envl < -30;
stidx = strfind([false; Lv].', [0 1])-1;
enidx = strfind([false; Lv].', [1 0]);
s = enidx - stidx;
for k = 1:numel(s)
ixr = stidx(k):enidx(k);
T{k} = TS{ixr,1};
S{k} = TS{ixr,2};
end
figure
hold on
for k = 1:numel(T)
plot(T{k}, S{k})
end
hold off
xlabel('x')
ylabel('y')
.
10 Commenti
Star Strider
il 3 Nov 2022
As always, my pleasure!
I worked for about an hour to do something with that last file, and could not.
.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Measurements and Spatial Audio in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!