Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Matlab

  • 18-03-2012 9:58pm
    #1
    Registered Users, Registered Users 2 Posts: 195 ✭✭


    hi folks
    i was wondering if anyone could recommend a book for learning how to use matlab? i have no previous experience in software like this so im really a newbie with it.


Comments

  • Registered Users, Registered Users 2 Posts: 3,533 ✭✭✭Daniel S


    MATLAB An Introduction with Applications by Amos Gilat


  • Registered Users, Registered Users 2 Posts: 13,104 ✭✭✭✭djpbarry


    00MARTZ00 wrote: »
    hi folks
    i was wondering if anyone could recommend a book for learning how to use matlab? i have no previous experience in software like this so im really a newbie with it.
    Do you currently have access to Matlab? Before forking out for a book, consider the help files - they're a pretty good place to start learning.


  • Registered Users, Registered Users 2 Posts: 195 ✭✭00MARTZ00


    djpbarry wrote: »
    Do you currently have access to Matlab? Before forking out for a book, consider the help files - they're a pretty good place to start learning.
    yeah i have access to it pal i just need to be able to use it properly for the course im going onto in september.


  • Registered Users, Registered Users 2 Posts: 13,104 ✭✭✭✭djpbarry


    00MARTZ00 wrote: »
    yeah i have access to it pal i just need to be able to use it properly for the course im going onto in september.
    If you're going into a course and Matlab is to be used, I'm sure they'll provide some instruction, no?


  • Registered Users, Registered Users 2 Posts: 195 ✭✭00MARTZ00


    djpbarry wrote: »
    If you're going into a course and Matlab is to be used, I'm sure they'll provide some instruction, no?

    Well its through advanced entry. we did a bridging module this year but i think it was "assumed" that you knew how to use matlab or it was "assumed" that you had previous programming experience (which we didnt). we did enough to get all assignments done but next year i want to be comfortable using it.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 13,104 ✭✭✭✭djpbarry


    Fair enough. All I can tell you is that I use Matlab fairly regularly and often need to read up on how to do something I've not done before. But, I've never had any need to go beyond the help documentation.


  • Registered Users, Registered Users 2 Posts: 1,638 ✭✭✭Turbulent Bill


    I think getting some help on how Matlab is supposed to be used would be a good start, i.e., use matrix operations wherever you can. For example, someone familiar with C would naturally use for-loops for linear algebra, whereas Matlab can easily operate on complete matrices. I think the latest releases are much better at for-loops (almost as fast as matrix operations), but I still think it's bad practice.

    Matlab has turned into a massive general-purpose maths platform, so I'd pick something specific to do with it rather than try to learn everything. As djpbarry said, the help files are good for specific things.


  • Registered Users, Registered Users 2 Posts: 195 ✭✭00MARTZ00


    I think getting some help on how Matlab is supposed to be used would be a good start, i.e., use matrix operations wherever you can. For example, someone familiar with C would naturally use for-loops for linear algebra, whereas Matlab can easily operate on complete matrices. I think the latest releases are much better at for-loops (almost as fast as matrix operations), but I still think it's bad practice.

    Matlab has turned into a massive general-purpose maths platform, so I'd pick something specific to do with it rather than try to learn everything. As djpbarry said, the help files are good for specific things.

    see i dont really know what your talking about here thats why i really need a book that starts from scratch.


  • Registered Users, Registered Users 2 Posts: 290 ✭✭davey101


    For what its worth your probably better off just getting familiar with the help section for now and do some tutorials based on these. As already mentioned. there are loads on the web if you look around.
    As far as what turblent bill is refering too, you would ideally have some programming background before using matlab. However the language can be simple Once you have identified what you are trying to do, and this will most likely come from your lecturer.

    http://www.mathworks.co.uk/help/techdoc/learn_matlab/bqr_2pl.html


  • Registered Users, Registered Users 2 Posts: 13,104 ✭✭✭✭djpbarry


    00MARTZ00 wrote: »
    see i dont really know what your talking about here thats why i really need a book that starts from scratch.
    Matlab is all about matrix operations - the base unit is the matrix, the idea being that scalars and vectors are essentially sub-sets of matrices, so the same line of thought can be applied to everything when designing algorithms. This makes it easy to scale up to multiple dimensions. It's one the platforms biggest strengths, but it also takes a while to get the hang of.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 195 ✭✭00MARTZ00


    thanks for the help lads


  • Registered Users, Registered Users 2 Posts: 484 ✭✭brownacid


    I found trying to teach myself matlab that going from a book isnt the best way to do it, if you just get stuck in, go through the help files and ask "how to do such and such" into google you'll generally pick it up easily enough. Of course you kinda have to have a base understanding of the maths that you are trying to do. Then you can break down in to sections and write your code to do each part.

    So in short, google and help are your friend, books get very tedious at least for me if you are just constantly turning teh page and trying to understand what they are tallking about.


  • Registered Users, Registered Users 2 Posts: 13,104 ✭✭✭✭djpbarry


    brownacid wrote: »
    I found trying to teach myself matlab that going from a book isnt the best way to do it, if you just get stuck in...
    Yep - generally the best way to learn how to use most applications is to just give it a go, work through some tutorials and learn by doing.
    brownacid wrote: »
    So in short, google and help are your friend, books get very tedious at least for me if you are just constantly turning teh page and trying to understand what they are tallking about.
    Books have their place - I find them useful for programming languages in particular. It can be useful to have a definitive reference to hand sometimes.


  • Registered Users, Registered Users 2 Posts: 442 ✭✭random.stranger


    00MARTZ00 wrote: »
    Well its through advanced entry. we did a bridging module this year but i think it was "assumed" that you knew how to use matlab or it was "assumed" that you had previous programming experience (which we didnt). we did enough to get all assignments done but next year i want to be comfortable using it.
    Matlab has turned into a massive general-purpose maths platform, so I'd pick something specific to do with it rather than try to learn everything. As djpbarry said, the help files are good for specific things.

    Maybe if you have a chat with the lecturer you'll have next year, they might be able to give you material you can cover in your own time. That way your work will be more focussed & relevent.

    I think doing exercises will be a lot more beneficial than reading books.


  • Registered Users, Registered Users 2 Posts: 195 ✭✭00MARTZ00


    thanks for the help folks


  • Registered Users, Registered Users 2 Posts: 2,945 ✭✭✭D-Generate


    Just to hit on djpbarry's point that understanding Matlab's ability to do matrix operations is the source of its strength. If you are doing a big data problem the last thing you want to do is have nested for loops and that is where Matlab excels. It is worth taking some time to get the hang of operating with vectors rather than working through the individual cells of a matrix.


  • Registered Users, Registered Users 2 Posts: 13,073 ✭✭✭✭bnt


    In addition to all the Matrix goodness, I'm getting quite a bit of mileage out of Structures, and arrays of them, in MATLAB.

    The open source program Octave is a near-clone of MATLAB - and its documentation is very good, I think.

    You are the type of what the age is searching for, and what it is afraid it has found. I am so glad that you have never done anything, never carved a statue, or painted a picture, or produced anything outside of yourself! Life has been your art. You have set yourself to music. Your days are your sonnets.

    ―Oscar Wilde predicting Social Media, in The Picture of Dorian Gray



  • Registered Users, Registered Users 2 Posts: 13,104 ✭✭✭✭djpbarry


    bnt wrote: »
    The open source program Octave is a near-clone of MATLAB - and its documentation is very good, I think.
    Oooohh, I haven't looked at Octave in a few years - a C++ API? Interesting. This definitely warrants further investigation.


  • Closed Accounts Posts: 2,957 ✭✭✭miss no stars


    I've found myself using matlab pretty much every day this year and found that I couldn't remember any of the stuff I"d done in college on it.

    As has been previously mentioned, the lecturers in your course should be willing to give you some of the exercises the class will hve previously done to get you up to speed... IF they've actually done much on it at all! Go to your current course coordinator and ask them to give you the name of someone (lecturer) from next year's course who can either point you at the relevant lecturer or who can let you know what sort of stuff has already been covered. They should be more than willing to help a proactive student.

    Secondly. You are surely not the very first student to make the transition????? The lecturers in question will have experienced students transferring in and will be aware of what they already do and do not know. They will account for this anyway?

    Thirdly. Help files and the mathworks website are where it's at with learning Matlab. No real way other than to get stuck in.

    Try and think of stuff that you already know how to do by hand and then make matlab do the work for you.

    I've attached an image of calculating and plotting trigonometric functions to get you started. Fully understanding everything in it should get you familiarised enough with matlab to be able to move a bit further with it. Write up what I've shown and get it to run by yourself, then do a bit more. For example, try and calculated the tan of the array by dividing the numbers in the sin_nums array by the numbers in the cos_nums array.... You'll see what people mean then about matlab working in matrices - you won't be able to just say sin_nums/cos_nums. You have to tell it to work elementwise and say sin_nums./cos_nums. That will make it divide the first element of sin_nums by the first element of cos_nums, then the second by the second and so on. + and - you don't need to worry about that for though. Just operations like multiply(*) and divide (/).

    When you're writing stuff, it's generally best to do so in the editor. You can write away there to your heart's content without matlab executing anything until you hit the little play symbol or F5. You can also tell it to execute certain parts of the script by highlighting it and hitting F9. You can then save what you've done in an 'm-file', that you can reopen, edit and play with to your heart's content :) You can also 'call' mfiles as function (look it up sometime ;) )

    Your matlab might not look like mine but don't worry, you can rearrange it to look however you like. Everything should still be there.

    Oh one last thing, if you're putting something in brackets or inverted commas, as soon as you open the bracket (or inverted comma), close it again immediately, then go back and type inside the brackets or inverted commas. It'll save you from the headwrecking experience if having an extra/one too few brackets somewhere and your script refusing to run and trying to figure out exactly WHERE you missed or put the extra one in :)

    enjoy!


  • Registered Users, Registered Users 2 Posts: 195 ✭✭00MARTZ00


    miss no stars that is amazing thanks a mil!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 484 ✭✭brownacid


    I've found myself using matlab pretty much every day this year and found that I couldn't remember any of the stuff I"d done in college on it.

    As has been previously mentioned, the lecturers in your course should be willing to give you some of the exercises the class will hve previously done to get you up to speed... IF they've actually done much on it at all! Go to your current course coordinator and ask them to give you the name of someone (lecturer) from next year's course who can either point you at the relevant lecturer or who can let you know what sort of stuff has already been covered. They should be more than willing to help a proactive student.

    Secondly. You are surely not the very first student to make the transition????? The lecturers in question will have experienced students transferring in and will be aware of what they already do and do not know. They will account for this anyway?

    Thirdly. Help files and the mathworks website are where it's at with learning Matlab. No real way other than to get stuck in.

    Try and think of stuff that you already know how to do by hand and then make matlab do the work for you.

    I've attached an image of calculating and plotting trigonometric functions to get you started. Fully understanding everything in it should get you familiarised enough with matlab to be able to move a bit further with it. Write up what I've shown and get it to run by yourself, then do a bit more. For example, try and calculated the tan of the array by dividing the numbers in the sin_nums array by the numbers in the cos_nums array.... You'll see what people mean then about matlab working in matrices - you won't be able to just say sin_nums/cos_nums. You have to tell it to work elementwise and say sin_nums./cos_nums. That will make it divide the first element of sin_nums by the first element of cos_nums, then the second by the second and so on. + and - you don't need to worry about that for though. Just operations like multiply(*) and divide (/).

    When you're writing stuff, it's generally best to do so in the editor. You can write away there to your heart's content without matlab executing anything until you hit the little play symbol or F5. You can also tell it to execute certain parts of the script by highlighting it and hitting F9. You can then save what you've done in an 'm-file', that you can reopen, edit and play with to your heart's content :) You can also 'call' mfiles as function (look it up sometime ;) )

    Your matlab might not look like mine but don't worry, you can rearrange it to look however you like. Everything should still be there.

    Oh one last thing, if you're putting something in brackets or inverted commas, as soon as you open the bracket (or inverted comma), close it again immediately, then go back and type inside the brackets or inverted commas. It'll save you from the headwrecking experience if having an extra/one too few brackets somewhere and your script refusing to run and trying to figure out exactly WHERE you missed or put the extra one in :)

    enjoy!

    Excellent post, well done for taking the time to write it up and explain it for the OP.

    One thing, do you actually write your code in the editor when its docked like that? I find I like to have the editor as large as possible to see more of teh code when I'm programming. I suppose its just down to preference, I've seen a few of my friends with their command window/workspace set up like yours but they hadn't actually realised you could undock the editor to make it bigger.


  • Registered Users, Registered Users 2 Posts: 9,514 ✭✭✭TheChizler


    brownacid wrote: »
    Excellent post, well done for taking the time to write it up and explain it for the OP.

    One thing, do you actually write your code in the editor when its docked like that? I find I like to have the editor as large as possible to see more of teh code when I'm programming. I suppose its just down to preference, I've seen a few of my friends with their command window/workspace set up like yours but they hadn't actually realised you could undock the editor to make it bigger.

    +1 for double monitor setup. Editor in one and help files in the other!


  • Closed Accounts Posts: 2,957 ✭✭✭miss no stars


    brownacid wrote: »
    Excellent post, well done for taking the time to write it up and explain it for the OP.

    One thing, do you actually write your code in the editor when its docked like that? I find I like to have the editor as large as possible to see more of teh code when I'm programming. I suppose its just down to preference, I've seen a few of my friends with their command window/workspace set up like yours but they hadn't actually realised you could undock the editor to make it bigger.

    Depends on what I'm doing tbh. If I'm starting to write something I'll undock it and get the bulk of the writing done, then when I go to start checking that it works I redock it and run line by line. I find having the editor docked allows me to see immediately if the correct result is appearing in the workspace... I also leave it docked if I'm making minor modifications. Suppose it's just down to preference really.


  • Registered Users, Registered Users 2 Posts: 936 ✭✭✭bassey


    Could anyone tell me if theres a way of creating an Excel type table of two arrays of data in MATLAB? I'm trying to get the height of a cylinder against the volume of it.


  • Registered Users, Registered Users 2 Posts: 484 ✭✭brownacid


    Put the two columns of data into a matrix so A = [height volume];

    Then if you want to output this file use

    save filename.txt A -ASCII

    Tis matrix can then be imported to excel and you have your table. Thats how I would do it but there may be a easier way in excel, IM not sure about putting titles on your columns in matlab tho, there is more than likely a way to include a string with the title but Im not sure of it.

    From a quick google you can find this
    http://www.mathworks.com/matlabcentral/newsreader/view_thread/90868

    I think my way may be easier and quicker


  • Closed Accounts Posts: 11 Robert Edmonds


    Honestly I learned just from using the help files in MATLAB. This certainly wasn't the way when I learned C or Fortran.


  • Closed Accounts Posts: 3,601 ✭✭✭cerastes


    I know Im digging up something old here,

    Id like to know does anyone know where there are courses I can practice this, ie some fundamentals so if I have to do anything with it in the future (which I intend to return to college to finish an engineering degree I started)

    I used it there, but the tutorials were just muddled through with the lecturer just telling us what to do as none of us had an experience in it. I would like to be able to use it and not enough time was allocated to it in the past.

    I'm still uncertain if it is useful for me to learn, but Id hoped to be able to present some maths based solutions for a project in something like this as I believe it might be a good way to present part of a project if my understanding that it could be used to model how something might perform in a maths based proof/answer. I dont want to waste time in college trying to figure it out as apart from assignments and study and likely work too, I dont want to get bogged down and sidetracked just by trying to figure it out at the moment I need it, hence the advance preparation.

    Basically, I have no clue about it, how much it can do but it seems to be in use and in colleges, so seems little point in me learning some other system or program.


  • Registered Users, Registered Users 2 Posts: 1,638 ✭✭✭Turbulent Bill


    There's no harm learning MATLAB, but to be honest if you're just looking for a general-purpose calculation tool you might as well start with Excel. It has bags of functions, reasonable visualisation and a gentler learning curve. I'm a fan of MATLAB, but I end up using Excel a lot more.

    Ultimately they're just tools to do the same job. Your time would be better spent working on the fundamentals of the problem, and let these guide you to the right tool.


  • Closed Accounts Posts: 3,601 ✭✭✭cerastes


    There's no harm learning MATLAB, but to be honest if you're just looking for a general-purpose calculation tool you might as well start with Excel. It has bags of functions, reasonable visualisation and a gentler learning curve. I'm a fan of MATLAB, but I end up using Excel a lot more.

    Ultimately they're just tools to do the same job. Your time would be better spent working on the fundamentals of the problem, and let these guide you to the right tool.

    Thanks for the reply, interesting, I guess Im not even sure if what Im considering can be done on matlab can be done on excel too, Im not even that familiar with excel but I have done some stuff on it from time to time.
    Not sure if excel can represent information the way matlab can.

    I saw by accident someone use it to model an aerodynamic profile.
    I thought it might be a useful tool to determine and alter a designed component to be effective.

    What is it used for? and how might that find a use in an engineering situation/problem?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,638 ✭✭✭Turbulent Bill


    cerastes wrote: »
    Thanks for the reply, interesting, I guess Im not even sure if what Im considering can be done on matlab can be done on excel too, Im not even that familiar with excel but I have done some stuff on it from time to time.
    Not sure if excel can represent information the way matlab can.

    I saw by accident someone use it to model an aerodynamic profile.
    I thought it might be a useful tool to determine and alter a designed component to be effective.

    What is it used for? and how might that find a use in an engineering situation/problem?

    It's used in a huge number of applications, anywhere where maths-based modelling is used. MATLAB is exceptionally good at things that Excel handles poorly (very large data sets, complex numbers etc.); they are very different tools.

    The thing is, you'd be much better off understanding the maths behind a problem and doing a simple hand calculation then charging straight into MATLAB for a complete solution. Most of my class were rubbish at MATLAB initially, but it was mainly due to our poor linear algebra skills rather than the software.


Advertisement