How to check if two equations are equal

조회 수: 5 (최근 30일)
kevin Russell
kevin Russell 2022년 2월 5일
답변: VBBV 2022년 2월 5일
Hello, I'm trying to verify if an equation is time-invariant or not time-invariant. So I'm putting two equations in a for loop to see if the values of each equation are equal. In theory, these values should be equal, but it is outputting, not time-invariant. Any help?
clear
syms t
x1(t)=cos(t);
y1(t)=1-2*x1(t-1);
x2(t)=cos(t-3);
y2(t)=1-2*x2(t-1);
for t=-pi():.1:pi()
Check_Y=y1(t-3);
Check_X=y2(t);
if Check_X~=Check_Y
disp('Not time invarient')
break
end
if t==-pi()+6.2
disp('Time invarient')
end
end
t=-pi():.1:pi();
figure
subplot(3,1,1)
plot(t,y1(t))
title('x(t):y(t)')
subplot(3,1,2)
plot(t,y2(t))
title('x(t-3):y(t)')
subplot(3,1,3)
plot(t,y1(t-3))
title('y(t-3)')

채택된 답변

VBBV
VBBV 2022년 2월 5일
clear
syms t
x1(t)=cos(t);
y1(t)=1-2*x1(t-1);
x2(t)=cos(t-3);
y2(t)=1-2*x2(t-1);
for t=-pi():.1:pi()
Check_Y=vpa(y1(t-3),2);
Check_X=vpa(y2(t),2);
if Check_X~=Check_Y
disp('Not time invarient')
break
end
if t==-pi()+6.2
disp('Time invarient')
end
end
t=-pi():.1:pi();
figure
subplot(3,1,1)
plot(t,y1(t))
title('x(t):y(t)')
subplot(3,1,2)
plot(t,y2(t))
title('x(t-3):y(t)')
subplot(3,1,3)
plot(t,y1(t-3))
title('y(t-3)')
Try with vpa for check variables.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by