how to create a fuction p(t)

2 views (last 30 days)
clowen
clowen on 19 Feb 2016
Commented: Star Strider on 21 Feb 2016
i have to plot s(t) where s(t)=p(t)cos(wt)-p(t-2*pi)cos(wt)+cos(t-(3*pi/2))sin(wt)-p(t-(5*pi/2))sin(wt) where p(t)=cos(t) for -pi/2 to pi/2 =0 for else where w=2*pi*100*10^3

Accepted Answer

Star Strider
Star Strider on 19 Feb 2016
This runs. I will let you determine if it produces the result you want:
w=2*pi*1.0E+5;
p = @(t) cos(t) .* ((-pi/2 <= t) & (t <= pi/2));
s = @(t) p(t).*cos(w*t)-p(t-2*pi).*cos(w*t)+cos(t-(3*pi/2)).*sin(w*2*t)-p(t-(5*pi/2)).*sin(w*t);
t = linspace(-pi, 2*pi);
figure(1)
plot(t, s(t))
grid

More Answers (0)

Categories

Find more on Animation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!