Upload
andry044
View
633
Download
8
Embed Size (px)
DESCRIPTION
MATLAB...good applications...
Citation preview
MATLAB ( Matrix Laboratory )
Komputasi – Visualisasi – Pemrograman
Simulink – GUI – M-File
Install versi 6.0 ke atasPilih ikon
Command WindowWorkspaceCommand HistoryPreferencesCurrent DirectoryLaunch PadMatlab di Internet
Memulai MATLAB
Dasar-Dasar Matrix
Matrix Khusus :
Zeros(3)
Ones(4,3)
Magic(5)
Eye(4)
Pascal(5)
User Defined :
A=[1 2 3;4 5 6;7 8 9]
B=A([1 3],[1 2])
C=A([3 2 1],:)
D=A(:,[3 2 1])
A(:,2)=[ ]
A=[A(:,1) [2 5 8]’ A(:,2)]
Operasi Matrix
PenjumlahanK=[2 3 4;1 6 2;8 2 4]
L=[1 5 2;-4 3 9;0 1 5]
M=K+L
PerkalianP=[5 2 -1;5 3 0;1 9 2]
Q=[0 -3 4;-1 2 9;6 2 7]
R=P*Q
Perkalian Matrix dan Skalar
W=[4 1 2;0 4 5;9 4 1]
k=3
X=k*W
PerpangkatanA=[2 6 4;5 1 9;5 2 9]
B=A.^3
C=A^3
DeterminanB=[6 3 9;3 1 6;0 4 1]
D=det(B)
InversI=inv(B)
TransposeT=A’
TT=A’’
Pemrograman M-File
Variablea.Sensitive caseb.Mengenali 31 karakter
Type
Logical,Char,Numeric(single,double,int,uint),Cell,Structure,java Classes,Function Handles
OperatorAritmatika,Relasi,Logika
M-FileScript,Function
Fungsi (Function)
Nama
diawali huruf
Argumenfunction [output]=nama(input)
Nargin & nargoutfunction [x1,x2]=akar(a,b,c)
if nargin<3
error(‘arginput td < 3’);
end;
x1=(-b+sqrt(b^2-4*a*c))/2*a;
x2=(-b-sqrt(b^2-4*a*c))/2*a;
Subfungsifunction [rata,tengah]=statistik(u)
n=length(u);
rata=rata_rata(u,n);
tengah=median(u,n)
function a=rata_rata(v,n)
a=sum(v)/n;
function m=median(v,n)
w=sort(v);
if rem(n,2)==1
m=w((n+1)/2);
else
m=(w(n/2)+w(n/2+1))/2;
end
>> x=[3 5 1 8 3 2 6 5];
>> [rata,nilai_tengah]=statistik(x)
Statemen Kontrol
If, else dan elseif
Switch
While
For
Continue
Break
Try-Catch
Perbandingan if dan switch-case
gol=input(‘gol?’)if (gol==1)
gapok=1000000elseif (gol==2)
gapok=1500000elseif (gol==3)
gapok=2000000else
gapok=3000000end
gol=input(‘gol?’)switch golcase 1
gapok=1000000case 2
gapok=1500000case 3
gapok=2000000case 4
gapok=3000000end
Grafik : Plot
x=0:pi/100:2*pi;
y=sin(x);
plot(x,y);
grid on
y2=sin(x-0.25);
y3=sin(x-0.5);
plot(x,y,x,y2,x,y3)
Subplot
x=0:0.01:2*pi;
y1=sin(2*x);
y2=cos(2*x);
y3=cos(2*x).*sin(2*x);
y4=cos(10*x).*sin(10*x);
subplot(2,2,1),plot(x,y1);
subplot(2,2,2),plot(x,y2);
subplot(2,2,3),plot(x,y3);
subplot(2,2,4),plot(x,y4);
Plot3 & Meshgrid
t=0:pi/100:10*pi;
plot3(sin(2*t),cos(2*t),t);
[p,q]=meshgrid([-4:0.05:4]);
r=p.*exp(-p.^2-q.^2);
plot3(p,q,r)
grid on
Semilogx & Semilogy
t=0:pi/30:2*pi;
y=exp(cos(t));
subplot(211),semilogx(t,y)
title('Semilogx');
subplot(212),semilogy(t,y)
title('Semilogy');
Plotyy
subplot(111) t=0:pi/10:2*pi; y=exp(cos(t)); plotyy(t,y,t,y,'plot','stem') grid on
t=0:900;A=1000;a=0.005;b=0.005;
z1=A*exp(-a*t); z2=sin(b*t); [haxes,hline1,hline2]=plotyy(t,
z1,t,z2,'semilogy','plot');
Tipe Grafik Lain
Pie dan Stem
Image (Imshow & Imhist)
GUIDE (GUI builDEr)
Berorientasi Visual = VB, delphi, Visual C,Visual Fox Pro, dll
Keunggulan :
* orientasi sains: skripsi,tesis,disertasi
* banyak fungsi built in dan toolbox
* ukuran FIG-file dan M-file kecil
* kemampuan grafis andal