Learning MATLAB

UkraineTrainUkraineTrain Registered User regular
So, I'm on my second year of my engineering degree and apparently I'm going to need to use MATLAB alot during my third year and quite possibly once I graduate. I spent most of first year thinking of it as pretty much as a calculator, I was pretty surprised to find out its apparently an object oriented programming language.

I know there are quite a few of you out there who are probably already pretty familiar with it and I'm just wondering if you could recommend some books or online tutorials?

UkraineTrain on


  • Options
    mcdermottmcdermott Registered User regular
    edited November 2007
    Well, my department requires this textbook (we buy it in one of our first sophomore courses, and they recommend you keep it), and it's decent. Pretty comprehensive, decently laid out, etc. I'd be surprised if there aren't cheaper or better options, though. But in general anytime I've needed to do anything it's been in there.

    For online tutorials, I don't know. I've also found google to be a great "reference," though...just punch in what you need to do with a +matlab on the end, and poke through the results. Probably not great for the more programming-oriented stuff, though.

    EDIT: Note that the above is very much a "textbook." Homework problems and all. It's pretty comprehensive, though, at least for anything you're likely to be doing anytime soon. I'm making the assumption that none of your future classes require any such textbook...you should probably poke around and see if they do, in which case you can just buy that early and start looking into it.

    mcdermott on
  • Options
    ZackSchillingZackSchilling Registered User regular
    edited November 2007
    I didn't learn MATLAB from a book but I'm fairly proficient with it. If you have any questions, you can ask them here and I can try to answer them.

    ZackSchilling on
  • Options
    WembleyWembley Registered User regular
    edited November 2007
    Just gonna stop in to point out how big of a geek I am. It's actually a functional programming language.

    Wembley on
  • Options
    VeegeezeeVeegeezee Registered User regular
    edited November 2007
    I've been using MATLAB scripting in a couple different types of research for a few years now, and I have to say, probably the single greatest way to learn is the help files. And to paraphrase a popular personality, I will jab forks into my eye sockets if I'm caught saying that about any software ever again.

    Seriously, they're incredible. Everything is spelled out in plain English for those new to scripting and programming, no prior experience required.

    Edit: For example, from the online documentation:
    MATLAB Function Reference


    Data gridding


    ZI = griddata(x,y,z,XI,YI)
    [XI,YI,ZI] = griddata(x,y,z,XI,YI)
    [...] = griddata(...,method)
    [...] = griddata(...,method,options)


    ZI = griddata(x,y,z,XI,YI) fits a surface of the form z = f(x,y) to the data in the (usually) nonuniformly spaced vectors (x,y,z). griddata interpolates this surface at the points specified by (XI,YI) to produce ZI. The surface always passes through the data points. XI and YI usually form a uniform grid (as produced by meshgrid).

    XI can be a row vector, in which case it specifies a matrix with constant columns. Similarly, YI can be a column vector, and it specifies a matrix with constant rows.

    [XI,YI,ZI] = griddata(x,y,z,XI,YI) returns the interpolated matrix ZI as above, and also returns the matrices XI and YI formed from row vector XI and column vector yi. These latter are the same as the matrices returned by meshgrid.

    [...] = griddata(...,method) uses the specified interpolation method:

    'linear' Triangle-based linear interpolation (default)'cubic'Triangle-based cubic interpolation'nearest'Nearest neighbor interpolation'v4'MATLAB 4 griddata method

    The method defines the type of surface fit to the data. The 'cubic' and 'v4' methods produce smooth surfaces while 'linear' and 'nearest' have discontinuities in the first and zero'th derivatives, respectively. All the methods except 'v4' are based on a Delaunay triangulation of the data. If method is [], then the default 'linear' method is used.

    [...] = griddata(...,method,options) specifies a cell array of strings options to be used in Qhull via delaunayn. If options is [], the default delaunayn options are used. If options is {''}, no options are used, not even the default.

    Occasionally, griddata might return points on or very near the convex hull of the data as NaNs. This is because roundoff in the computations sometimes makes it difficult to determine if a point near the boundary is in the convex hull.


    XI and YI can be matrices, in which case griddata returns the values for the corresponding points (XI(i,j),YI(i,j)). Alternatively, you can pass in the row and column vectors xi and yi, respectively. In this case, griddata interprets these vectors as if they were matrices produced by the command meshgrid(xi,yi).


    The griddata(...,'v4') command uses the method documented in [3]. The other griddata methods are based on a Delaunay triangulation of the data that uses Qhull [2]. For information about Qhull, see http://www.qhull.org/. For copyright information, see http://www.qhull.org/COPYING.txt.


    Sample a function at 100 random points between ±2.0:
    x = rand(100,1)*4-2;  y = rand(100,1)*4-2;
    z = x.*exp(-x.^2-y.^2);

    x, y, and z are now vectors containing nonuniformly sampled data. Define a regular grid, and grid the data to it:
    ti = -2:.25:2; 
    [XI,YI] = meshgrid(ti,ti);
    ZI = griddata(x,y,z,XI,YI);

    Plot the gridded data along with the nonuniform data points used to generate it:
    plot3(x,y,z,'o'), hold off


    See Also

    delaunay, griddata3, griddatan, interp2, meshgrid


    [1] Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Transactions on Mathematical Software, Vol. 22, No. 4, Dec. 1996, p. 469-483. Available in PDF format at http://www.acm.org/pubs/citations/journals/toms/1996-22-4/p469-barber.

    [2] National Science and Technology Research Center for Computation and Visualization of Geometric Structures (The Geometry Center), University of Minnesota. 1993.

    [3] Sandwell, David T., "Biharmonic Spline Interpolation of GEOS-3 and SEASAT Altimeter Data", Geophysical Research Letters, 2, 139-142,1987.

    [4] Watson, David E., Contouring: A Guide to the Analysis and Display of Spatial Data, Tarrytown, NY: Pergamon (Elsevier Science, Inc.): 1992.

    And almost anything you'll need is documented like that.

    Veegeezee on
  • Options
    alcoholic_engineeralcoholic_engineer Registered User regular
    edited November 2007
    I have found that my professors actually have given pretty decent tutorials on how to do all the crap that we need to do for labs. They tend to be relatively in depth, and have taught me quite a bit.

    As well, ask some professors if there are any resources they would recommend to allow you to get a jump on understanding it if you feel interested.

    alcoholic_engineer on
  • Options
    jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    edited November 2007
    My university used Maple. Seriously, what the hell?

    jackal on
  • Options
    jarekjarek Registered User regular
    edited November 2007
    Also you might want to take a look at Octave (http://www.gnu.org/software/octave/)... It's effectively a free version of Matlab [I'm pretty sure the basic language is identical, although some of the less common functions are named differently]. Useful for learning basic Matlab without shelling out cash for the student version [though you'll probably want to get that eventually].

    jarek on
  • Options
    BallmanBallman Registered User regular
    edited November 2007
    I use matlab a lot. Throw my name in the hat for people that will be willing to answer questions about it. For instance, last semester I threw together a script that would generate simulated gamma-ray spectrum data for various radioisotopes, and recently I've been trying to come up with an adaptive time-step script for simulating systems of ODEs.

    Even the tutorials on mathworks.com really help beginners. Just getting used to the idea that every variable is inherently a matrix (and understanding the differences between matrices and cells in matlab) helps a lot.

    Ballman on
  • Options
    Marty81Marty81 Registered User regular
    edited November 2007
    jackal wrote: »
    My university used Maple. Seriously, what the hell?


    I don't know, what? Matlab is mainly for number-crunching and standard analytic techniques, whereas Maple is mainly for symbolic calculations (though lots of people have released Maple packages for more esoteric calculations and analytic techniques).

    Marty81 on
  • Options
    UkraineTrainUkraineTrain Registered User regular
    edited November 2007
    Yea thats for all the advice guys. I think im gonna pick up the textbook mcdermott mentioned and just chug through it. Should give me an edge when I do my class in computational methods and with some other problems.

    UkraineTrain on
  • Options
    Britjade91Britjade91 Registered User regular
    So i'm about to use Matlab for the first time in the first year of my PhD, and coming from a purely biomed background I have NO idea about the engineering/mathematic/computational side of this.

    I'm going to be using it to create a math model for my biological system representing receptor-ligand interactions of the immune system in the cancer microenvironment.

    So, i'm pretty scared. Terrified, actually.

    Any advice on Matlab (breakdown of what it is, why used in biological systems, how to visualise it, good tutorials or textbooks for this purpose etc). I have some ideas, but i'd love to know others opinions more experienced than me!


  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    @Britjade91 I'd probably make a Help/Advice thread about it. You'll be more likely to get some attention that way.

    Matlab's not too difficult if you understand the math involved. It's the programming that always gets people. I'm sure if you Google "Matlab beginner tutorials" you can find some really helpful material.

Sign In or Register to comment.