Anda di halaman 1dari 6

3.

Modifikasi program halaman 114-115

A. List program di matlab


clc;
clear all;
disp('================================')
disp('PROGRAM MENGHITUNG NILAI AKHIR MAHASISWA');
disp('nama kelompok 1')
disp('Geokomputasi')
disp('Anggota kelompok :')
disp('Hamliana,Darlin,La Ode Muhammad Farhan & Phil Richard Saranaga')
disp('================================')
%mendefinisikan input
NT=input('Nilai Tugas=');
NTS=input('Nilai Tengah Semester=');
NP=input('Nilai Praktikum=');
NAS=input('Nilai Akhir Semester=');
%menghitung Nilai akhir
N=(2*NT+3*NTS+4*NP+6*NAS)/10;
if (81<=N)&&(N<=100)
disp(['Nilai Akhir=',num2str(N), 'Grade=A,Ket=Lulus'])
elseif (61<=N)&&(N<=80)
disp(['Nilai Akhir=',num2str(N), 'Grade=B,Ket=Lulus'])
elseif (41<=N)&&(N<=60)
disp(['Nilai Akhir=',num2str(N), 'Grade=C,Ket= Lulus'])
elseif (21<=N)&&(N<=40)
disp(['Nilai Akhir=',num2str(N), 'Grade=D,Ket=Hampir Tidak Lulus'])
elseif (0<=N)&&(N<=20)
disp(['Nilai Akhir=',num2str(N), 'Grade=E,Ket=Tidak Lulus'])
end

B.Hasil di Command Window


4. Halaman 120

A.List program di matlab


x = -2*pi:pi/20:2*pi;
y = sin(x);
plot(x,y);
title ('Plot of sin(x) vs x');
grid on;

B.Hasil di Figure
5. Halaman 122

A.List program di matlab


x = -pi:pi/20:pi;
y1 = sin(x);
y2 = cos(x);
plot(x,y1,'b-');
hold on;
plot(x,y2,'k--');
hold off;
legend ('sin x','cos x');

B. Hasil di figure
6. Halaman 123 & lanjutannya pada 125

A. List program di matlab


figure(1)
subplot(2,1,1)
x = -pi:pi/20:pi;
y = sin(x);
plot(x,y);
title('Subplot 1 title');
subplot(2,1,2)
x = -pi:pi/20:pi;
y = cos(x);
plot(x,y);

title('Subplot 2 title');

B. Hasil Figure
9. Halaman 132
A. List program di Matlab

% Script file: ideal_gas.m


%
% Purpose:
% This program plots the pressure versus volume of an
% ideal gas.
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 01/16/07 S. J. Chapman Original code
%
% Define variables:
% n -- Number of atoms (mol)
% P -- Pressure (kPa)
% R -- Ideal gas constant (L kPa/mol K)
% T -- Temperature (K)
% V -- volume (L)
% Initialize nRT
n = 1; % Moles of atoms
R = 8.314; % Ideal gas constant
T = 273; % Temperature (K)
% Create array of input pressures. Note that this
% array must be quite dense to catch the major
% changes in volume at low pressures.
P = 1:0.1:1000;
% Calculate volumes
V = (n * R * T) ./ P;
% Create first plot
figure(1);
loglog( P, V, 'r-', 'LineWidth', 2 );
title('\bfVolume vs Pressure in an Ideal Gas');
xlabel('\bfPressure (kPa)');
ylabel('\bfVolume (L)');
grid on;
hold on;
% Now increase temperature
T = 373; % Temperature (K)
% Calculate volumes
V = (n * R * T) ./ P;
% Add second line to plot
figure(1);
loglog( P, V, 'b--', 'LineWidth', 2 );
hold off;
% Add legend
legend('T = 273 K','T = 373 k');
B.Hasil di Figure