Selasa, 01 April 2014

Simulasi Jenis Akar Persamaan Kuadrat

Sintaksisnya:

clc; clear all;
disp('==============================================');
disp('Program: Simulasi Jenis Akar Persamaan Kuadrat');
disp('Programer: Syaharuddin');
disp('==============================================');
a=input('a = '); b=input('b = '); c=input('c = ');
D=b^2-4*a*c;
x(1)=(-b+sqrt(D))/2*a; x(2)=(-b-sqrt(D))/2*a;
s=(-b)/2*a; p=(-D)/4*a;
disp(['Nilai D       = ',num2str(D)]);
disp(['Akar-akar     = ',num2str(x)])
disp(['Sumbu Simetri = ',num2str(s)]);
disp(['Titik Balik   = ',num2str(p)]);
if D>0
    disp('Jenis Akar    = Bilangan Real Berlainan')
elseif D<0
    disp('Jenis Akar    = Imajiner / Khayal')
else D=0
    disp('Jenis Akar = Kembar')
end
X = [x(1)-5:0.25:x(2)+5]; f = a.*(X.^2)+b.*X+c;
plot(X,f)
grid on
xlabel('Domain Fungsi'); ylabel('Range Fungsi')
title(['f(x) = ',num2str(a),'x^2 + ',num2str(b),'x + ',num2str(c)])
text(mean(X),mean(f),['Akar = ',num2str(x)])
legend('Grafik Fungsi Kuadrat')

Reaksi:

0 komentar:

Poskan Komentar

Catatan Kuliah

Syaharuddin Al Musthafa