Info
此问题已关闭。 请重新打开它进行编辑或回答。
Making Vectors of data from time series
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Brent Kostich
2020-5-28
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.
回答(1 个)
Maadhav Akula
2020-5-31
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 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!