clc diary 'Pendahuluanmatlab1.doc' diary on sin(pi/3) ans = 0.8660 clc diary off diary on %1. Ketik perintah berikut di commond window sin(pi/3) ans = 0.8660 2^(7/2) ans = 11.3137 sqrt(3) ans = 1.7321 log(10) ans = 2.3026 %2. Ketik perintah berikut di commond window A=[2 1 0; -1 2 2; 0 1 4]; %Input 3x3 matrix b=[1;2;3]; %Input column vector soln=A\b soln = 0.2500 0.5000 0.6250 soln1=A.\b ??? Error using ==> ldivide Matrix dimensions must agree. B=[2 3 -2; 0 1 6; 2 3 4]; A/B ans = -1.3333 -2.0000 2.3333 2.8333 3.5000 -3.3333 0.3333 1.0000 -0.3333 A./B Warning: Divide by zero. ans = 1.0000 0.3333 0 -Inf 2.0000 0.3333 0 0.3333 1.0000 A.*B ans = 4 3 0 0 2 12 0 3 16 A*B ans = 4 7 2 2 5 22 8 13 22 A>B ans = 0 0 1 0 1 0 0 0 0 B>A ans = 0 1 0 1 0 1 1 1 0 (A>B)|(B>5) ans = 0 0 1 0 1 1 0 0 0 %3. Buat matriks berikut pada commond window A=[4 -2 -4; 1 5 -3; 6 -8 -5] A = 4 -2 -4 1 5 -3 6 -8 -5 A(2,3) ans = -3 A([1 3 6]) ans = 4 6 -8 A(1,:) ans = 4 -2 -4 A(:,2) ans = -2 5 -8 inv(A) ans = 2.7222 -1.2222 -1.4444 0.7222 -0.2222 -0.4444 2.1111 -1.1111 -1.2222 A' ans = 4 1 6 -2 5 -8 -4 -3 -5 l=ones(3,3) l = 1 1 1 1 1 1 1 1 1 l./A ans = 0.2500 -0.5000 -0.2500 1.0000 0.2000 -0.3333 0.1667 -0.1250 -0.2000 %4. Lakukan perintah berikut untuk membuat plot grafik x=[0:0.1:2*pi] x = Columns 1 through 10 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 Columns 11 through 20 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 Columns 21 through 30 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 Columns 31 through 40 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 Columns 41 through 50 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000 4.8000 4.9000 Columns 51 through 60 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 Columns 61 through 63 6.0000 6.1000 6.2000 figure(1), plot(x,sin(x)) figure(2), plot(x,sin(x),'.',x,cos(x),'o') %5. Ketik perintah berikut: help meshgrid MESHGRID X and Y arrays for 3-D plots. [X,Y] = MESHGRID(x,y) transforms the domain specified by vectors x and y into arrays X and Y that can be used for the evaluation of functions of two variables and 3-D surface plots. The rows of the output array X are copies of the vector x and the columns of the output array Y are copies of the vector y.
[X,Y] = MESHGRID(x) is an abbreviation for [X,Y] = MESHGRID(x,x). [X,Y,Z] = MESHGRID(x,y,z) produces 3-D arrays that can be used to evaluate functions of three variables and 3-D volumetric plots.
For example, to evaluate the function x*exp(-x^2-y^2) over the range -2 < x < 2, -2 < y < 2,
[X,Y] = meshgrid(-2:.2:2, -2:.2:2); Z = X .* exp(-X.^2 - Y.^2); mesh(Z)
MESHGRID is like NDGRID except that the order of the first two input and output arguments are switched (i.e., [X,Y,Z] = MESHGRID(x,y,z) produces the same result as [Y,X,Z] = NDGRID(y,x,z)). Because of this, MESHGRID is better suited to problems in cartesian space, while NDGRID is better suited to N-D problems that aren't spatially based. MESHGRID is also limited to 2-D or 3-D.
Class support for inputs x, y, z: float: double, single
See also <a href="matlab:help surf">surf</a>, <a href="matlab:help slice">sl ice</a>, <a href="matlab:help ndgrid">ndgrid</a>. Reference page in Help browser <a href="matlab:doc meshgrid">doc meshgrid</a> help subplot SUBPLOT Create axes in tiled positions. H = SUBPLOT(m,n,p), or SUBPLOT(mnp), breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for for the current plot, and returns the axis handle. The axes are counted along the top row of the Figure window, then the second row, etc. For example,
plots income on the top half of the window and outgo on the bottom half.
SUBPLOT(m,n,p), if the axis already exists, makes it current. SUBPLOT(m,n,p,'replace'), if the axis already exists, deletes it and creates a new axis. SUBPLOT(m,n,p,'align') places the axes so that the plot boxes are aligned instead of preventing the labels and ticks from overlapping. SUBPLOT(m,n,P), where P is a vector, specifies an axes position that covers all the subplot positions listed in P. SUBPLOT(H), where H is an axis handle, is another way of making an axis current for subsequent plotting commands.
SUBPLOT('position',[left bottom width height]) creates an axis at the specified position in normalized coordinates (in in the range from 0.0 to 1.0).
SUBPLOT(m,n,p, PROP1, VALUE1, PROP2, VALUE2, ...) sets the specified property-value pairs on the subplot axis. To add the subplot to a specific figure pass the figure handle as the value for the 'Parent' property.
If a SUBPLOT specification causes a new axis to overlap an existing axis, the existing axis is deleted - unless the position of the new and existing axis are identical. For example, the statement SUBPLOT(1,2,1) deletes all existing axes overlapping the left side of the Figure window and creates a new axis on that side - unless there is an axes there with a position that exactly matches the position of the new axes (and 'replace' was not specified), in which case all other overlapping axes will be deleted and the matching axes will become the current axes.
SUBPLOT(111) is an exception to the rules above, and is not identical in behavior to SUBPLOT(1,1,1). For reasons of backwards compatibility, it is a special case of subplot which does not immediately create an axes, but instead sets up the figure so that the next graphics command executes CLF RESET in the figure (deleting all children of the figure), and creates a new axes in the default position. This syntax does not return a handle, so it is an error to specify a return argument. The delayed CLF RESET is accomplished by setting the figure's NextPlot to 'replace'. Reference page in Help browser <a href="matlab:doc subplot">doc subplot</a> help slice SLICE Volumetric slice plot. SLICE(X,Y,Z,V,Sx,Sy,Sz) draws slices along the x,y,z directions at the points in the vectors Sx,Sy,Sz. The arrays X,Y,Z define the coordinates for V and must be monotonic and 3-D plaid (as if produced by MESHGRID). The color at each point will be determined by 3-D interpolation into the volume V. V must be an M-by-N-by-P volume array.
SLICE(X,Y,Z,V,XI,YI,ZI) draws slices through the volume V along the surface defined by the arrays XI,YI,ZI.
SLICE(V,Sx,Sy,Sz) or SLICE(V,XI,YI,ZI) assumes X=1:N, Y=1:M, Z=1:P.
SLICE(...,'method') specifies the interpolation method to use. 'method' can be 'linear', 'cubic', or 'nearest'. 'linear' is the default (see INTERP3).
SLICE(AX,...) plots into AX instead of GCA.
H = SLICE(...) returns a vector of handles to SURFACE objects.
Example: To visualize the function x*exp(-x^2-y^2-z^2) over the range -2 < x < 2, -2 < y < 2, -2 < z < 2,
[x,y,z] = meshgrid(-2:.2:2, -2:.25:2, -2:.16:2); v = x .* exp(-x.^2 - y.^2 - z.^2); slice(x,y,z,v,[-1.2 .8 2],2,[-2 -.2])
See also <a href="matlab:help meshgrid">meshgrid</a>, <a href="matlab:help i nterp3">interp3</a>. Reference page in Help browser <a href="matlab:doc slice">doc slice</a> %Penjelasan masing-masing perintah %Help meshgrid %Fungsi meshgrid digunakan untuk membuat jaring-jaring (grid) pada bidang x-y %yang diatasnya terdapat permukaan fungsi. Perintah ini akan mentransformasi vek tor x dan y %pada domain tertentu menjadi bentuk array X dan Y yang dapat digunakan untuk me ngevaluasi fungsi dengan dua variabel dan plot permukaan 3-D. %Help subplot %Function subplot digunakan untuk membuat suatu figure dapat memuat lebih dari s atu gambar. Perintah sublot didefinisikan sebagai : %subplot(n,m,i) %Perintah tersebut membagi suatu figure menjadi suatu matriks m x n area grafik dan i berfungsi sebagai indeks penomoran gambar. %Subplot dinomori dari kiri ke kanan dimulaidari baris teratas. %Help slice %digunakan untuk melakukan irisan data ortogonal melalui volumetrik diary off