Basic MATLAB - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Basic MATLAB

Description:

Basic MATLAB – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 21
Provided by: mikes4
Category:
Tags: matlab | basic | rand

less

Transcript and Presenter's Notes

Title: Basic MATLAB


1
Basic MATLAB
2
Matlab
  • Post-processer
  • Graphics
  • Analytical solution comparisons

3
Vectors
  • gtgt a1 2 3 4
  • a
  • 1 2 3 4
  • gtgt a'
  • ans
  • 1
  • 2
  • 3
  • 4

4
Autofilling and addressing Vectors
  • gt a10.23'
  • a
  • 1.0000
  • 1.2000
  • 1.4000
  • 1.6000
  • 1.8000
  • 2.0000
  • 2.2000
  • 2.4000
  • 2.6000
  • 2.8000
  • 3.0000
  • gtgt a(23)
  • ans

5
xy Plots
  • gtgt x1 3 6 8 10
  • gtgt y0 2 1 3 1
  • gtgt plot(x,y)

6
Matrices
  • gtgt b1 2 3 45 6 7 8
  • b
  • 1 2 3 4
  • 5 6 7 8
  • gtgt b'
  • ans
  • 1 5
  • 2 6
  • 3 7
  • 4 8

7
Matrices
  • gtgt b2.2ones(4,4)
  • b
  • 2.2000 2.2000 2.2000 2.2000
  • 2.2000 2.2000 2.2000 2.2000
  • 2.2000 2.2000 2.2000 2.2000
  • 2.2000 2.2000 2.2000 2.2000

8
Reshape
  • gtgt a19
  • a
  • 1 2 3 4 5 6 7 8
    9
  • gtgt bsquarereshape(a,3,3)
  • bsquare
  • 1 4 7
  • 2 5 8
  • 3 6 9
  • gtgt

9
Load and if
  • a load(filename) (semicolon suppresses echo)
  • if(1)
  • else
  • end

10
For
  • for i 110
  • end

11
Grad
  • dhdx,dhdygradient(h)

12
BMP Output
  • bsqrand(100,100)
  • bmp1 output
  • e(,,1)1-bsq r
  • e(,,2)1-bsq g
  • e(,,3)ones(100,100) b
  • imwrite(e, 'junk.bmp','bmp')
  • image(imread('junk.bmp'))
  • axis('equal')

13
Contours
  • h
  • contour(h)
  • C,Hcontour(h)
  • Clabel(C,H)

14
Contours (load data, prepare matrix)
  • rhoload('rho_frame0012_subs00.dat')
  • p_vectorrho/3
  • rows100
  • columns20
  • for j1columns
  • j
  • for i1rows
  • p(i,j)p_vector(j(i-1)columns)
  • Get rid of '0 pressure' solids that
    dominate pressure field
  • if p(i,j)0
  • p(i,j)NaN
  • end
  • end
  • end

15
Contours
  • C,Hcontour(p)
  • clabel(C,H)
  • axis equal

16
Quiver (vector plots)
  • gtgt scale10
  • gtgt drand(100,4)
  • gtgt quiver(d(,1),d(,2),d(,3),d(,4),scale)

17
Quiver (and Quiver3)
  • uv_vectorload('u_frame0012_subs00.dat')
  • rows100
  • columns20
  • for j1columns
  • j
  • for i1rows
  • u(i,j)uv_vector(j(i-1)20,1)
  • v(i,j)uv_vector(j(i-1)20,2)
  • end
  • end
  • hold on
  • quiver(u,v)

18
Streamline
  • Stream stream2(u,v,5,100)
  • streamline(Stream)

19
Streamlines
  • Stream stream2(u,v,120,100ones(20,1))
  • streamline(Stream)
  • (This is for streamlines starting at y 100 from
    x 1 to 20 along the x axis. Different
    geometries will require different starting
    points.)

20
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com