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!