How to use hanning window to get 5 cyles of sine waves?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
load ( 'x.mat' )
t = 0: 10 * pi; % 5 cyeles
sf = 200e3; % frequency
sinewave = sin (2 * pi * sf * x); % gen continuous sine waves
w = hanning (length (sinewave)); % hann
figure (1);
plot (w);
% I do not know where to include the 5 cycles here
採用された回答
Andrey Kiselnikov
2019 年 8 月 12 日
編集済み: Andrey Kiselnikov
2019 年 8 月 12 日
First of all you should properly define your data: "t = 0: 10 * pi; % 5 cyeles" I assume that you would like to define something like this "t = 0:1/sf:10*pi", more over "t" never used. Can you describe your task more properly?
>> t = 0: 10 * pi
t =
Columns 1 through 17
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Columns 18 through 32
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
13 件のコメント
Ramesh Bala
2019 年 8 月 12 日
Hi I want to generate 5 cycles,200 kHz sine waves and my x is a time vector
Ramesh Bala
2019 年 8 月 12 日
I want to generate for this time vector 'x' ,5 cycle sine waves and rest of the values to be as '0'
Andrey Kiselnikov
2019 年 8 月 12 日
Can you attach your *.mat file with your time vector here?
Ramesh Bala
2019 年 8 月 12 日
alright attached
Andrey Kiselnikov
2019 年 8 月 12 日
編集済み: Andrey Kiselnikov
2019 年 8 月 12 日
This code was made for better understanding, it's quite not optimal.
If this answer is ok, mark it as accepted or let me know what's wrong.
load ( 'x.mat' )
sf = 200e3; % frequency
x1= 2*pi*sf*x;
five_cycles = find(x1 < 10*pi);
five_cycles = x1(five_cycles);
sine_five_cycles = sin(five_cycles);
w = hanning (length (five_cycles));
subplot(2,1,1);
plot(sine_five_cycles);
subplot(2,1,2);
stem (w);
Ramesh Bala
2019 年 8 月 12 日
The code looks good,one question here
the sine_five_cycles values goes upto 1*64 for the time vector ,so the rest of the values are to be taken as '0' for remaining time values?
Andrey Kiselnikov
2019 年 8 月 12 日
"find" return the result of comparison between array members and value 10*pi, the result has the same length as x1 array and it's logical type. Then we take from x1 the values that meet our condition by x1(five_cycles).
Ramesh Bala
2019 年 8 月 12 日
HI
But the total time for this should be 2.5e-5
f = 200*10^3; % sine frequency[Hz]
sf = 10*10^6; % sampling frequency [Hz]
n = 5; % number of sine periods [-]
T = 1/f; % sine period [s]
tt = n*T; % total time [s]
but the code of yours gives 30 ?
So,I think it's converted to radians ,instead of using seconds.So,is that the reason.
Also,how to make it a modulated signal for the entire time vector,as the values are changing
Ok?
plot(x(1:length(sine_five_cycles)),sine_five_cycles);
Ramesh Bala
2019 年 8 月 12 日
What I meant was the sine wave looks similar,will that be in modulated state as the time increases
f = 200*10^3; % sine frequency[Hz]
sf = 10*10^6; % sampling frequency [Hz]
n = 5; % number of sine periods [-]
T = 1/f; % sine period [s]
tt = n*T; % total time [s]
t = 0:1/sf:tt; % time vector
burst = sin(2*pi*f*t) .* hanning(size(t,2))';
plot(t,burst);
In this example the sine waves starts with 0,then increases and then decreases - a modulate signal.
How can i make the same with the 'x' time vector?
Ramesh Bala
2019 年 8 月 12 日
this gives me a modulated signal (increasing-decreasing)
f = 200*10^3; % sine frequency[Hz]
n = 5; % number of sine periods [-]
T = 1/f; % sine period [s]
tt = n*T; % total time [s]
burst = sin(2*pi*f*x) .* hanning(size(x,2))';
plot(x,burst);
but it's not correct as it should be only for 5 signals and then rest of the vecot should be '0'( a flat signal)

Ramesh Bala
2019 年 8 月 12 日
So,how to make it to start as modulated signal and then after 5 cycles to be flat signal =0
mm99
2019 年 12 月 28 日
Hi!
Did you get the result? I need the same thing and stucked in the same moment.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
製品
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
