how to plot y(t)
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tell me what is wrong with my code ? i didnt get the expected graph
Root Raised Cosine Filter..

clc;clear all; close all;
fs=10;
Ts = 1/fs;
c = 10;
t = -1:0.01:1;
b=1;
T=1/fs;
Nt=-Ts/(2*b);
Pt=Ts/(2*b);
y=@(t) ((1/Ts)*(1+(b*((4/pi)-1)))) .*(t==0) + ((b/(Ts*sqrt(2))) * ( ((1+2/pi)*(sin(pi/(4*b)))) + ((1-(2/pi))*cos(pi/(4*b))) )) ...
.*((t==Nt) | (t==Pt)) + ((1/Ts).*((sin(pi*(t/Ts)*(1-b)) + (4*b*(t/Ts).*(cos(pi*(t/Ts)*(1+b))))) / (pi*(t/Ts).*(1-(4*b*(t/Ts)).^2)))) ...
.*((t~=Nt) & (t~=Pt) & (t~=0));
plot(t,y(t));
0 commentaires
Réponses (2)
KSSV
le 22 Jan 2021
Check the expressions thoroughly....not sure did I enter correct.
fs=10;
Ts = 1/fs;
c = 10;
t = -1:0.01:1;
b=1;
T=1/fs;
Nt=-Ts/(2*b);
Pt=Ts/(2*b);
h = zeros(size(t)) ;
for i = 1:length(t)
if t(i) ==0
h(i) = (1/Ts)*(1+(b*((4/pi)-1))) ;
elseif abs(t(i)) == Ts/(4*b)
h(i) = b/(Ts*sqrt(2))*((1+2/pi)*sin(pi/(4*b))+(1-2/pi)*cos(pi/(4*b))) ;
else
h(i) = 1/Ts*(sin(pi*t(i)/Ts*(1-b))+4*b*t(i)/Ts*cos(pi*t(i)/Ts*(1+b)))/(pi*t(i)/Ts*(1-(4*b*t(i)/Ts)^2)) ;
end
end
plot(t,h);
3 commentaires
VBBV
le 13 Nov 2022
Modifié(e) : VBBV
le 13 Nov 2022
h=@(t) (((1/Ts).*((sin(pi*(t/Ts)*(1-b)) + (4*b*(t/Ts).*(cos(pi*(t/Ts)*(1+b)))))...
./ (pi*(t/Ts).*(1-(4*b*(t/Ts)).^2)))) ).*(t~=0);
% ^^ ^^
% example
t = 0;
y = 1/t % a very large number which cannot be known
To get the desired output, you need to suppy the vector t using your anonymous function
fs=10;
Ts = 1/fs;
c = 10;
t = -1:0.01:1 % give this vector
b=1;
T=1/fs;
Nt=-Ts/(4*b);
Pt=Ts/(4*b);
h = zeros(size(t)) ;
h=@(t) (((1/Ts).*((sin(pi*(t/Ts)*(1-b)) + (4*b*(t/Ts).*(cos(pi*(t/Ts)*(1+b)))))...
./ (pi*(t/Ts).*(1-(4*b*(t/Ts)).^2)))) ).*(t~=0)
y = h(t);
idx = find(t == 0);
y(idx) = (1/Ts)*(1+(b*((4/pi)-1)));
plot(t,y)
Luan
le 13 Nov 2022
I am a new intow, would anyone show me how to plot
y(t)= 1/3(2e^-t+1-3e^-2t)
Thanks
0 commentaires
Voir également
Catégories
En savoir plus sur Get Started with Signal Processing Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


