Last active
May 7, 2017 02:13
-
-
Save RianWardana/db3576780c5b26500132e7b5946d933c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [output] = proyek(string) | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SISTEM DISKRIT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
string = strrep(string, 'n', 't'); | |
string = strrep(string, '[', '('); | |
string = strrep(string, ']', ')'); | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UJI LINEARITY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
syms t; | |
syms a; | |
syms b; | |
% jika y1(t) = ax1(t), dimana x1(t) = t | |
x = @(t) a*t; | |
y1 = eval(string); | |
% jika y2(t) = bx2(t), dimana x2(t) = t^2 | |
x = @(t) b*(t^2); | |
y2 = eval(string); | |
% jika y3(t) = ax1(t) + bx2(t) | |
x = @(t) (a*t) + (b*(t^2)); | |
y3 = eval(string); | |
% membandingkan y3(t) dengan y1(t) + y2(t) | |
% substitusi t dengan angka arbitrary untuk membandingkan kedua hasil | |
if (subs(y3, t, 35) == subs(y1 + y2, t, 35)) | |
display('Sistem linear.'); | |
linear = true; | |
else | |
display('Sistem tak linear.'); | |
linear = false; | |
end | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% UJI TIME-INVARIANCE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% jika y1(t) = x1(t), dimana x1(t) = t | |
x = @(t) t; | |
y1 = eval(string); | |
% jika y1(t) digeser menjadi y1(t-t0), dimana nilai t0 arbitrary | |
y1geser = subs(eval(string), t, (t-3)); | |
% jika y2(t) = x1(t-t0), nilai t0 arbitrary | |
x = @(t) t-3; | |
y2 = eval(string); | |
% membandingkan apakah y2(t) = y1(t-t0) | |
% substitusi t dengan angka arbitrary untuk membandingkan kedua hasil | |
if (subs(y2, t, 15) == subs(y1geser, t, 15)) | |
display('Sistem time-invariant.'); | |
ti = true; | |
else | |
display('Sistem time-varying.'); | |
ti = false; | |
end | |
if (linear && ti) | |
display('Sistem LTI.'); | |
else | |
display('Bukan sistem LTI.'); | |
end | |
display(' '); | |
display(' '); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment