CEE15 Introduction to Computing for Civil Engineers 1

CEE15 Introduction to Computing for Civil Engineers 1 - CEE...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CEE 15 Introduction to Computing for Civil Engineers 1 An Introduction to MATLAB (Version Release 12) Chapter 1 Introduction to MATLAB 1.1. MATLAB Windows Table 1.1 MATLAB Windows Window Purpose Command Window Main window, enters variables, runs programs Figure Window Contains output from graphic commands Editor Window Creates and debugs script and function files Help Window Provides help information Launch Pad Window Provides access to tools, demos, and documentation Command History Window Logs commands entered in the Command Window Workspace Window Provides information about the variables that are used Current Directory Window Shows the files in the current directory 1.2. MATLAB Commands MATLAB : Matrix Laboratory. The basic element of MATLAB is matrix. MATLAB commands are similar to the way we express engineering steps in mathematics, writing computer solutions in MATLAB is much quicker than writing computer solutions using a high-level language such as C or Fortran. Select the MATLAB program from a menu in your operating system (Windows or UNIX). MATLAB command window will appear and you should see the MATLAB prompt ( >> ), which tells you that MATLAB is waiting for you to enter a command. The command to exit MATLAB is quit or exit . If you want to save all the variables in the workspace before you quit, use the command save . This automatically saves all the variables in a file called matlab.mat . After quitting MATLAB if you re-enter once again and if you want to use all the variables in the workspace then use the command load, the default file name is matlab.mat. The commands clear all or clear removes all the variables from the memory. clc To clear command window. clg To clear graphic window. clf To clear current figure and thus clear the graph window. Ctrl C is used to generate a local abort within MATLAB (in case of infinite loop). help a help menu appears. To get help on a particular topic, use topic For example, help disp . MATLAB is a case-sensitive language, for example, TIME and time are two different variables. The command who lists the variables that you have defined. The command whos lists the variables along with their sizes and whether they have nonzero imaginary part. Also who and whos will list a variable named ans (in command window). It stores the value of expression that is latest computed but not given a name. For example,
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CEE 15 Introduction to Computing for Civil Engineers 2 a=[2 3]; b=[3 5]; a+b; a.*b; who; The above program will have an output as the following (if you type them in command window): Your variables are: a ans b where ans stores the value of a.*b. M-files ( Test1.m, Test2.m,…etc) are used to execute sequence of commands that are stored in the file in addition to executing commands entered through the key board. M-file (also known as the script file ) is a file of ASCII characters and is generated using an editor or word processor. To execute the commands in the M-file say Test1.m
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/28/2011 for the course CE 13972 taught by Professor Chow during the Spring '09 term at University of California, Berkeley.

Page1 / 23

CEE15 Introduction to Computing for Civil Engineers 1 - CEE...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online