フィルターのクリア

Quick question about elementwise

2 ビュー (過去 30 日間)
Tom
Tom 2012 年 1 月 26 日
編集済み: Helder Pinheiro 2022 年 6 月 26 日
I have a piece of code that works without the .* and another that doesn't - can't work out why. This is the one that works
close all
clear all
fo = 4; %Frequency of the sine wave
Fs = 100; %Sampling rate
Ts = 1/Fs; %Sampling time interval
t = 0:Ts:1-Ts;
n = length(t); %Number of samples
x = 2*sin(2*pi*fo*t);
[XfreqD,freqRng] = positiveFFT(x,Fs);
stem(freqRng,abs(XfreqD));
Also, the function that one uses is here -
function[X,freq]=positiveFFT(x,Fs)
N=length(x);
k=0:N-1;
T=N/Fs;
freq=k/T; %Create the frequency range
X=fft(x)/N; %normalise the data
cutOff = ceil(N/2);
X = X(1:cutOff);
freq = freq(1:cutOff);
Then my code - the one that doesn't work is here. It's asking or .^ etc.
close all; clear all
t0=0.05;w0=600*pi;q=5;
%t=linspace(-0.1,0.1,fs);
fs = 100; %Sampling rate
Ts = 1/fs; %Sampling time interval
t = 0:Ts:1-Ts;
n = length(t); %Number of samples
x=exp(-(t/t0)^2)*cos(w0*(1-q*t)*t);
[XfreqD,freqRng] = positiveFFT(x,fs);
stem(freqRng,abs(XfreqD));
This version works - but I have no idea whether it's right or not. Is there a good way of checking?
close all; clear all t0=0.05;w0=600*pi;q=5; %t=linspace(-0.1,0.1,Fs); Fs = 100; %Sampling rate Ts = 1/Fs; %Sampling time interval t = 0:Ts:1-Ts; n = length(t); %Number of samples x=exp(-(t/t0).^2).*cos(w0*(1-q.*t).*t); [XfreqD,freqRng] = positiveFFT(x,Fs); stem(freqRng,abs(XfreqD));
  3 件のコメント
Matt Fig
Matt Fig 2012 年 11 月 2 日
I have a piece of code that works without the .* and another that doesn't - can't work out why. This is the one that works
close all
clear all
fo = 4; %Frequency of the sine wave
Fs = 100; %Sampling rate
Ts = 1/Fs; %Sampling time interval
t = 0:Ts:1-Ts;
n = length(t); %Number of samples
x = 2*sin(2*pi*fo*t);
[XfreqD,freqRng] = positiveFFT(x,Fs);
stem(freqRng,abs(XfreqD));
Also, the function that one uses is here -
function[X,freq]=positiveFFT(x,Fs)
N=length(x);
k=0:N-1;
T=N/Fs;
freq=k/T; %Create the frequency range
X=fft(x)/N; %normalise the data
cutOff = ceil(N/2);
X = X(1:cutOff);
freq = freq(1:cutOff);
Then my code - the one that doesn't work is here. It's asking or .^ etc.
close all; clear all
t0=0.05;w0=600*pi;q=5;
%t=linspace(-0.1,0.1,fs);
fs = 100; %Sampling rate
Ts = 1/fs; %Sampling time interval
t = 0:Ts:1-Ts;
n = length(t); %Number of samples
x=exp(-(t/t0)^2)*cos(w0*(1-q*t)*t);
[XfreqD,freqRng] = positiveFFT(x,fs);
stem(freqRng,abs(XfreqD));
This version works - but I have no idea whether it's right or not. Is there a good way of checking?
close all; clear all t0=0.05;w0=600*pi;q=5; %t=linspace(-0.1,0.1,Fs); Fs = 100; %Sampling rate Ts = 1/Fs; %Sampling time interval t = 0:Ts:1-Ts; n = length(t); %Number of samples x=exp(-(t/t0).^2).*cos(w0*(1-q.*t).*t); [XfreqD,freqRng] = positiveFFT(x,Fs); stem(freqRng,abs(XfreqD));
Helder Pinheiro
Helder Pinheiro 2022 年 6 月 26 日
編集済み: Helder Pinheiro 2022 年 6 月 26 日

サインインしてコメントする。

採用された回答

Wayne King
Wayne King 2012 年 1 月 26 日
Hi Tom, I don't think you need the dot multiplication on q, just
x=exp(-(t/t0).^2).*cos(w0*(1-q*t).*t);
On whether it's right or not, it's not readily apparent to me what you're trying to do with (cos(w0*(1-q*t).*t)
  1 件のコメント
Tom
Tom 2012 年 1 月 27 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by