The MATLAB commands that generated the graph are shown in green below, following each command is a comment preceded by %. So, when the 'end' command is entered above, the computer executes the following commands: Note that 'execution' of a for loop doesn't start until the end command is entered. The for command specifies an index variable and a list of values for the variable, the commands in the loop are executed once for each value in the index list. Graphing is 'built-in' in MATLAB and only requires one line, of the form 'plot(x,y)' where x is a vector of the the horizontal coordinates of the points to be graphed and y is a vector of the vertical coordinates of the points to be plotted.Ī 'for loop' causes the list of commands between the for and end commands to be executed repeatedly. And, if the truth be known, drawing graphs is one of the big thrills in physics and engineering. Also, it has features that make it very easy to produce graphs. One of the beauties of the language is that it was designed for scientists and engineers, and not computer programmers, so it is very 'user' oriented. There is now (2006 onward) an appendix in each CWT volume giving a very brief introduction to MATLAB programming. It is also a programming language that is very easy to use. Using MATLAB as a calculator is just the beginning. Typing the name of the variable after a prompt causes its value to be printed, thus Individual elements in a list are referenced by following the variable name with an index into the list in parentheses, thus b(1) references the first element, b(2) the second, and so on. Stores a five element list in b, the first element is 2.1, the second 8, and so on. A value is assigned to a variable ( 'a' in the line below) with an assignment command of the formĪ variable can also store a list of values (called a vector). A named memory location is called a 'variable'. That is, you can edit only the parts you want, you don't have to retype the entire line. MATLAB is much more convenient than a handheld calculator, because, if you type in a long expression and evaluate it, and then discover you've made a mistake, or you want to change it for any reason, you can enter an 'up arrow' and the previous line you entered will reappear after the prompt, and you can edit the line and reenter it. After the prompt, type in an expression followed by (Enter) and FREEMAT/OCTAVE will evaluate the expression and print the answer. How difficult is that? When you run the program it comes up in a window and prints a prompt '>'. So I recommend that you download either FREEMAT or OCTAVE right now, and at a mimimum, learn to use it as a calculator. FREEMAT and OCTAVE have all the features of MATLAB.Ĭlick here for the OCTAVE Home Page. FREEMAT and OCTAVE are totally legal and free, and can be downloaded from the web. However, now there are free clones of MATLAB available, my favorites are FREEMAT and OCTAVE. So, why have I waited till now to tell you about this fantastic tool? Because MATLAB is expensive. It is also a super calculator, and all the calculations for the exercises were also done with my most convenient calculator, MATLAB. MATLAB is the programming language of choice for many analytical engineering projects, and all the graphs in CWT were created using MATLAB. New Computational Calculus versus Old Analytical Calculus New in 2013 - MMCC - Mathematical ModelingĬWT Vol 4 - Good Vibrations - Fourier Analysis and the LaPlace Transform
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |