How to add Hann 5 cycles to the sine wave plot?

I would like to know how to add cycle to the sine plots?
The below one is a sine plot continuous how to make it short for only 5 cycles?where x here is the time and 200 is the load (kHz)
plot(x,sin(2*pi*200e3*x))

2 Comments

One full cycle of sine is 2pi
You should make your argument of sine: 0 .. 2pi*5
Change your x such that:
0 ... 2pi*200e3 0 ... 2pi*5
Hi Daravo
But my x is time vector
load('x.mat')
sf=200e3;
sinewave=sin(2*pi*sf*x);
figure(1);
plot(x, sinewave);
The above code gives a continuous sine plot
Note : kindly put your answers in the answer section as this will help me to accept it and vote it
Thanks

Sign in to comment.

 Accepted Answer

One full cycle of sine is 2pi
You should make your argument of sine: 0 .. 2pi*5
img11.png

14 Comments

load ( 'x.mat')
sf = 200e3;
for cycle = 0:2*pi*5;
sinewave = sin (cycle * sf * x);
figure (1);
plot (x, sinewave);
end
something as such with a loop?
Your code doesn't work :(
Please use special button for code inserting
23Untitled.png
This should work
x = 0:31;
cycle = 0:2*pi*5;
sinwave = sin(cycle);
plot(x,sinwave)
I want to add the load 200 kHz too That's why that sf is there
But the argument of sin() can't be 200
Can't you add it before sin?
200*sin()
load ( 'x.mat')
cycle = 0:2*pi*5;
sinewave = 200e3*sin(cycle*x);
figure (1);
plot (x, sinewave);
% i think it may give dimension error if I add 200e3?
If you want multiply two vectors you should use dot
cycle.*x
For shorter expression you can write this
2e5*sin()
still some dimension issues
sinewave = 2E5*sin(cycle.*x);
Can't you do your calculation without x?
no my x is a vector which is 1*4096 double and this indicates the time.
Can you accept my answer?
Ah kien problem Thank you so much :)

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Release

R2018a

Tags

Community Treasure Hunt

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

Start Hunting!