sin (pi/3) ans = 0.8660 2^(7/2) ans = 11.3137 sqrt(3) ans = 1.7321 log(10) ans = 2.3026 %Ketikkan perintah berikut di command window A=[2 1 0;-1 2 2;0 1 4]; %Kita inputkan matriks 3x3 %Kita inputkan colomn vector B=[1;2;3]; soln=A/B ??? Error using ==> mrdivide Matrix dimensions must agree. %perintah soln diatas tidak berjalan karena menggunakan / 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 9 14 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 %Buatlah matriks berikut pada command 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 I=ones(3,3) I = 1 1 1 1 1 1 1 1 1 I./A ans = 0.2500 -0.5000 -0.2500 1.0000 0.2000 -0.3333 0.1667 -0.1250 -0.2000 %Lakukan Perintah berikut untuk membuat plot grafik x=[0:0.1:2*pi] x = Columns 1 through 8 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 Columns 9 through 16 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 Columns 17 through 24 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 Columns 25 through 32 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000 Columns 33 through 40 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 Columns 41 through 48 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000 Columns 49 through 56 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 Columns 57 through 63 5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 figure(1), plot(x,sin(x)) figure(2), plot(x,sin(x),'.',x,cos(x),'o') %Ketikkan 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 dari perintah-perintah diatas : %Fungsi meshgrid digunakan untuk membuat jaring-jaring (grid) pada %bidang x-y yang diatasnya terdapat permukaan fungsi. Perintah ini akan %mentransformasi vektor x dan y pada domain tertentu menjadi bentuk array X dan %Y yang dapat digunakan untuk mengevaluasi fungsi dengan dua variabel dan plot %permukaan 3-D. %Untuk memplot 3 dimensi, anda harus membuat grid tiap titik dalam domain x-y ; %Matlab command meshgrid : %x=a:dc:b; %y=c:dy:d; %[X,Y]=meshgrid(x,y); %Jadi fungsi meshgrid digunakan untuk memplot grafik dalam bentuk 3 dimensi. %Penjelasan dari perintah subplot : %Fungsi SUBPLOT digunakan untuk membuat suatu figure yang dapat memuat lebih dar i satu gambar. %Subplot ini ditampilkan dalam dua dimensi (2-D) %Sintak : Subplot (n_baris, n_kolom, i_grafik) %Penjelasan dari perintah slice : %Slice merupakan volumetrik visualisasi saja. %perintahnya adalah : %SLICE(V,Sx,Sy,Sz) or SLICE(V,XI,YI,ZI) assumes X=1:N, Y=1:M, Z=1:P %SLICE(AX,...) plots into AX instead of GCA.H = SLICE(...) returns a vector of h andles to SURFACE objects. %Contohnya : untuk memvisualisasi x*exp(-x^2-y^2-z^2) dengan 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]) %Berikut contoh masing2 perintah : X = [1 2 3]; Y = [4 5 6 7]; [X,Y]=meshgrid(x,y) ??? Undefined function or variable 'y'. [X,Y]=meshgrid(x, y) ??? Undefined function or variable 'y'. [X,Y]=meshgrid(X,Y) X = 1 2 3 1 2 3 1 2 3 1 2 3 Y = 4 4 4 5 5 5 6 6 6 7 7 7 subplot(1,2,1),mesh(X,Y,f(X,Y)) ??? Undefined command/function 'f'. subplot(1,2,1),mesh(X,Y,(X,Y)) ??? subplot(1,2,1),mesh(X,Y,(X,Y)) | Error: Incomplete or misformed expression or statement. plot,mesh(X,Y) ??? Error using ==> plot Not enough input arguments. mesh(X,Y) colormap hsv xlabel('X') ylabel('Y') x=0:pi/20:pi; y=x; y=x; [X,Y]=meshgrid(x,y); f=inline('sin(2*x).*cos(3/2*y)','x','y') f = Inline function: f(x,y) = sin(2*x).*cos(3/2*y) subplot(1,2,1),mesh(X,Y,f(X,Y)) diary off