how to plot a time series from row 1000 to 3000

3 visualizzazioni (ultimi 30 giorni)
Hello and have a good day
I have a time series and I wanna plot 3D for t=0.1:0.001:0.3
Here is my code for all the time series
LD6 = load('output_a_f_LL_bus5.mat');
Data = LD6.Id_6.Data;
t = LD6.t.Time;
figure
plot3(Data(:,1), Data(:,2), t)
grid on
xlabel('Id')
ylabel('Iq')
zlabel('time')
How can I plot3D the time series after the 1000th row (or for the times between 0.1 to 0.3)?
  2 Commenti
Dyuman Joshi
Dyuman Joshi il 15 Ott 2023
You are using output_a_f_LL_bus5.mat to load the variables but you have provided a different .mat file.
Atefeh
Atefeh il 15 Ott 2023
Yes, You are right, Here is the output file

Accedi per commentare.

Risposta accettata

Voss
Voss il 15 Ott 2023
LD6 = load('output_a_f_LL_bus5.mat');
Data = LD6.Id_6.Data;
t = LD6.t.Time;
figure
idx = t >= 0.1 & t <= 0.3;
plot3(Data(idx,1), Data(idx,2), t(idx))
grid on
xlabel('Id')
ylabel('Iq')
zlabel('time')

Più risposte (1)

dpb
dpb il 15 Ott 2023
Modificato: dpb il 16 Ott 2023
d=dir('*bus*.mat');
load(d.name,'Id_6')
whos
Name Size Bytes Class Attributes Id_6 1x1 72372 timeseries ans 1x47 94 char cmdout 1x33 66 char d 1x1 1157 struct
head(Id_6)
timeseries with properties: Events: [] Name: '' UserData: [] Data: [3001×3 double] DataInfo: [1×1 tsdata.datametadata] Time: [3001×1 double] TimeInfo: [1×1 tsdata.timemetadata] Quality: [] QualityInfo: [1×1 tsdata.qualmetadata] IsTimeFirst: 1 TreatNaNasMissing: 1 Length: 3001
ix=(Id_6.Time>=0.1)&(Id_6.Time<=0.3);
plot3(Id_6.Data(ix,1), Id_6.Data(ix,2), Id_6.Time(ix))
grid on
xlabel('Id')
ylabel('Iq')
zlabel('time')
I'd strongly suggest to convert over to using timetable instead of timeseries; I've not found anything really useful at all about the implementation of the time series objects; the syntax has generally been more in the way than helpful; even the doc suggests it. Unfortunately, it's another case where an experimental new data class was released into the wild and while it (like the ill-fated Statistics TB dataset class) proved to be less than an optimal solution, now it exists and seemingly will have to be carried around as excess baggage forever.
ADDENDUM:
In my own code here, I'd have written the above as
ix=iswithin(Id_6.Time,0.1,0.3);
where iswithin is my utility function kept in a Utilities folder on the matlabpath just behind the working directory
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
end
This "syntactic sugar" function makes top level code much simpler to write/read and is particularly valuable when there are multiple ranges, etc., ...

Categorie

Scopri di più su Data Import and Analysis 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!

Translated by