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

1 visualización (últimos 30 días)
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)

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 5 de Jun. de 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 comentario
Rama a
Rama a el 5 de Jun. de 2021
Editada: Rama a el 5 de Jun. de 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

Iniciar sesión para comentar.

Más respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 15 de Jun. de 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*--')

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by