Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Making Vectors of data from time series
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This has likely been asked several times, I'm just not asking it in the right way to find all the other answers. SO thank you for your patience.
I have a cycle of data where the signal is on and then off for 10 seconds. How do I extract the data that represents ON and put that into new vectors? So from one time series I end up with 10 vectors.
3 commentaires
Brent Kostich
le 28 Mai 2020
I would recommend using the "Import Data" tool from the MATLAB "Home" tab. This not only makes the import process simple, you can auto-generate code for future imports. Or of course you can hand code the import process. xlsread or readtable would be useful if you go the manual route.
In terms of data analysis, I think you pretty much have the main idea. Try using the find function to locate the index points at which the data crosses the x-axis, which based on your data is just zero. From there, use the indices to create seperate vectors from your original data set.
Réponses (1)
Maadhav Akula
le 31 Mai 2020
Hi,
As Brent pointed out you can use the find function to sove your problem, you can have a look at the following code:
pos = true;
a = 1;
b = 1;
pos_wave = cell(3,2);
neg_wave = cell(3,2);
while ~isempty(y)
if pos
k = find(y < 0, 1 ,'first');
pos_wave{a,1} = y(1:k-1);
pos_wave{a,2} = t(1:k-1);
y = y(k:end);
t = t(k:end);
a = a + 1;
pos = 0;
else
k = find(y > 0, 1 ,'first');
neg_wave{b,1} = y(1:k-1);
neg_wave{b,2} = t(1:k-1);
y = y(k:end);
t = t(k:end);
b = b + 1;
pos = 1;
end
end
where y and t are the values of Sinewave and time respectively from the provided Excel Sheet.
Hope this helps!
0 commentaires
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!