clear clc %gunakan perintah for, %untuk a = 1 : 5 %grafiknya %v0 = 0 % a = 1 : 5 %t = 1 : 0.1 : 10 %x = v0*t + 1/2 * a * t.^2 %plot (t,x) for a = 1 : 5 v0 = 0 t = 1 : 0.1 : 10 x = v0*t + 1/2 * a * t.^2 plot (t,x) hold on grid on end
WHILE
clear clc %gunakan perintah while, i = 1 while i <= 5 i = i + 1 end
clear clc v0 = 0 a = 1:5 t = 1 : 0.1 : 10 i = 1; while i <= length (a) x = v0*t + 1/2 * a(i) * t.^2 i = i + 1 ; hold on grid on plot (t,x) end
CONDITIONAL STATEMENT
clear clc disp ('====================') disp ('Penentuan Kelulusan') disp ('=====================') nilai = input ( 'Masukan Nilai Anda = ') if (nilai >= 50) disp ('ANDA LULUS') else
clear clc disp ('====================') disp ('Penentuan Kelulusan') disp ('=====================') toefl = input ( 'Masukan Nilai toefl Anda = ') if ( toefl >= 601) & (toefl <= 670) disp ( 'Nilai toefl anda mantul') elseif ( toefl >= 501) & (toefl <= 600) disp ( 'Nilai toefl anda mantap') elseif ( toefl >= 401) & (toefl <= 500) disp ( 'Nilai toefl anda standar') else ( toefl >= 400) disp ('Belajar Lagi') end