sinc function doesnt work...
Ältere Kommentare anzeigen
My main code
clear all
close all
clc
T=0.1;
A=1;
tau=T/2;
kmax=20;
t0=tau/2;
%%
f0=1/T;
t=(0:0.0001:1)*5*T;
xsin=sin(2*pi*f0*t);
x=zeros(size(t));
ii1=find(xsin>=0);
x(ii1)=1;
figure(1)
plot(t,x), ylim([-0.5 1.5])
kk=-kmax:1:kmax;
Xk=func_Fourier_series_periodic_pulse(T,tau,t0,A,kk);
figure(2)
stem(kk,abs(Xk))
And my function code for "func_Fourier_series_periodic_pulse"
function Xk=func_Fourier_series_periodic_pulse(T,tau,t0,A,k)
f0=1/T;
Xk=(A*tau/T)*(sinc(k*f0*tau)).*exp(-j*2*pi*k*f0*t0);
There was an error saying
Incorrect number or types of inputs or outputs for function 'sinc'
I don't know what I did wrong... can someone help me...
Akzeptierte Antwort
Weitere Antworten (1)
The code runs fine here.
clear all
close all
clc
T=0.1;
A=1;
tau=T/2;
kmax=20;
t0=tau/2;
%%
f0=1/T;
t=(0:0.0001:1)*5*T;
xsin=sin(2*pi*f0*t);
x=zeros(size(t));
ii1=find(xsin>=0);
x(ii1)=1;
figure(1)
plot(t,x), ylim([-0.5 1.5])
kk=-kmax:1:kmax;
Xk=func_Fourier_series_periodic_pulse(T,tau,t0,A,kk);
figure(2)
stem(kk,abs(Xk))
Perhaps you have a version of the sinc function shadowing the Matlab function and defined with a different signature? What is the output of
which sinc -all
function Xk=func_Fourier_series_periodic_pulse(T,tau,t0,A,k)
f0=1/T;
Xk=(A*tau/T)*(sinc(k*f0*tau)).*exp(-j*2*pi*k*f0*t0);
end
1 Kommentar
Seungjun Lee
am 13 Okt. 2022
Kategorien
Mehr zu Code Performance finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

