which one of these is the right sol.? and let me know my mistakes please ..

1 view (last 30 days)
xb (t)= r(t ) - r(t-A ) - r(t-B ) + r(t-C )
A = 3, B = 4 and C = 4.
which one of these is the right sol.
and let me know my mistakes please
syms Xb t;
y1=t.*heaviside(t);
y2=(t-3).*heaviside(t-3);
y3=(t-4).*heaviside(t-4);
y4=(t-4).*heaviside(t-4);
Xb=y1-y2-y3+y4;
fplot(Xb);
xlabel('t');
ylabel('Xb(t)');
title (' xb(t)= r(t ) - r(t-3 ) - r(t-4 ) + r(t-4 ) ');
***************************************************************
syms t
A=3
B=4
C=4
t= 0: 0.02:5;
u=t>= 0;
u1=t>= 1;
X= t.*u-(t-A).*u1-(t-B).*u1+(t-C).*u1;
plot(t,X)

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 5 Jun 2021
Both are accurate and you can get the same results by changing this in the 1st one:
fplot(Xb, [0, 5]);
In the second one, you should not make t symbolic.
Note that the second one is computationally more efficient.
  1 Comment
Rama a
Rama a on 5 Jun 2021
Edited: Rama a on 5 Jun 2021
thanks
so the second code should be like this ?
A=3
B=4
C=4
t= 0: 0.02:5;
u=t>= 0;
u1=t>= 1;
X= t.*u-(t-A).*u1-(t-B).*u1+(t-C).*u1;
plot(X);
and I want you to run the two codes please .. there is a difference between between the plot of the first code and the second one from 1 to 3 on Y axis

Sign in to comment.

More Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 15 Jun 2021
Both gives the same results, if you fix in the second one the time boundary value for u1.
...
A=3;
B=4;
C=4;
t= 0: 0.02:5;
u=t>= 0;
u1=t>= 3; % Start at 3rd second
X= t.*u-(t-A).*u1-(t-B).*u1+(t-C).*u1;
plot(t,X, 'r*--')

Categories

Find more on Symbolic Math Toolbox 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!