Filter löschen
Filter löschen

I need a code to separate each cycle of sine wave.

6 Ansichten (letzte 30 Tage)
Primo
Primo am 27 Dez. 2014
Beantwortet: youjarr am 8 Jul. 2019
I need a code to separate each cycle of a sine wave. Suppose I have a sine wave with 10 cycle, so I need each cycle separated sata. I have attached an image to make it clear.

Antworten (2)

Star Strider
Star Strider am 27 Dez. 2014
This works:
t = linspace(0,10*pi,200);
x = sin(t);
mcs = x .* circshift(x, [0 -1]);
zxix = find(mcs <= 0);
for k1 = 1:2:size(zxix,2)-1
zx(k1) = interp1(x(zxix(k1):zxix(k1)+1), t(zxix(k1):zxix(k1)+1), 0);
end
figure(1)
plot(t, x)
hold on
plot(zx, zeros(size(zx)), '+r', 'MarkerSize',10)
hold off
grid
The ‘mcs’ variable detects the nearest zero-crossings, ‘zxix’ is their indices, and ‘zx’ uses interp1 to calculate the ‘t’ (the independent variable) coordinate corresponding to the actual zero-crossing. The plot displays the signal and the zero-crossings that distinguish the various cycles of your sine wave.

youjarr
youjarr am 8 Jul. 2019
Hey guys,
i know this is an old one but i can´t use this on my signals? And im not understanding why.
Maby a dumb one but I hope someone sees my mistake.
Thanks in advance.
In the attachment u will find my data for testingsin.png

Kategorien

Mehr zu View and Analyze Simulation Results finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by