6 views

Uploaded by Mutiara Istiqomah

- ADVANCED NOISE and Vibration Analysis
- Insilico Desigh of Bio-reactors
- Machine Vision Toolbox for MATLAB.pdf
- Matlab Introduction
- A Quicstart guide to MATLAB GUI k Start Guide to MATLAB GUI for Controlling Arduino Create Graphical User Interface and Command Arduino in Few Hours. - Magesh Jayakumar
- MATLAB Robotics toolkit
- Ode Solvers
- Basic Simulink Tutorial 012005
- 02 - Quantitative Security Analysis - Master - Matlab Web
- Attention-From-Motion: A Factorization Approach for Detecting Attention Objects in Motion
- MATLAB Cheat Sheet2
- TUTORIAL Computer and Geosciences Potensoft
- Introduction to Matlab.ppt
- Linear Algebra and Numerical Analysis
- The Automatic Control Telelab- A User-Friendly Interface for Distance Learning
- Tutorial 2
- Image Processing PPT
- Fdi 2009 Matlab
- 50gSolving Linear Systems Using Matrices
- Matlab Tut Basic

You are on page 1of 3

page-1

The purpose of this orientation is to allow you to get acquaintance with MATLAB in the math lab. Once you know how to get into the MATLAB, you will be given several exercises so that you can practice some commands in MATLAB for our MA237 class. Furthermore, you can use MATLAB as a computational tool for your homework. A primer, which contains many useful hints and commands, can be purchased at University Supestore for a little amount $. MATLAB is an interactive and command based language. A line of input (a command) is typed in after a >> prompt. When you are finished typing in the command, hit the Enter or Return key. MATLAB will then immediately execute the command and display the result. You cannot correct a command once it is entered. The only thing you can do is to enter a corrected version of the command. Help Feature: The up and down arrow keys can be used to move backward and forward through the list of commands which you have previously entered. If you need to change a command, especially a long one, use the error keys to bring it to the prompt and correct it before pressing the Enter key. PART 1: STEP-BY-STEP INSTRUCTIONS OF USING MATLAB 1. Access to MATLAB. After you turn on the computer, insert your disk in driver A, use mouse to press the Start button and then select Math and select matlab. 2. Now you are in the MATLAB screen and you will see the MATLAB prompt >>. 3. Open a record file. It is a good habit to keep a record of your work. To do that type diary a:pract.txt <Enter> (or some other file name). 4. Define matrices. Let us define a number of matrices. >> A=[1 2 3; 4 5 6; 7 8 9] Alternatively, you can create the same matrix by >> A=[1, 2, 3; 4, 5, 6; 7, 8, 9]; Note: Please notice the difference when you have ; and when you dont have ; after each line. Now, lets generate a column vector b by typing >>b=[1; 1; 2] Once you hit the Enter key, you see the column vector b is displayed. However, if you enter a row vector, you should do >>r = [1, 2, 3] To generate the augmented matrix, type >>C=[A, b]; 5. Row operations >> C([1,2],:)=C([2,1],:) >> C(1,:)=2*C(1,:) %swap R1 and R2 %R1=2R1

Update e:\student\ma237\matlab\orient.doc

by

7/6/2013

ORENTATION OF MATLAB

page-2

6. Gaussian Elimination. We will use MATLAB commands to solve the example 7 on page 10 in the book. >>A=[0 2 1; 3, 5, -5; 2 4 -2], b=[-2; 1; 2] >>C=[A, b] >>C([1,3],:)=C([3,1],:) %swap R1 and R3 >>C(1,:) = * C(1,:) % *R1 >>C(2,:)=C(2,:)-3*C(1,:) %R2 3R1 >>C(2,:) = -C(2,:) %(-1)*R2 >>C(3,:) = C(3,:) 2*C(2,:) %R3 2R2 Now the matrix C is in a triangular form. We can find the solution by backward solve: >>x(3)=C(3,4)/C(3,3) >>x(2)=(C(2,4)-C(2,3)*x(3))/C(2,2) >>x(1)=(C(1,4)-C(1,3)*x(3)-C(1,2)*x(2))/C(1,1) The solution is in the vector x. >>x Let us change the matrix A back to the original one. You may use the up arrow key to find it; or you can retype the matrix A >>A=[1,2,3; 4,5,6;7,8,9]; Now let us consider the linear system Au = b. Is this system consistent? If so, write out the general solution. Before you exit, dont forget to close your diary file >>diary off As an exercise, solve the same problem above by Gauss-Jordan elimination.

Other Tips: % comment line. The MATLAB will ignore what you type after the sign %. Use the cursor up and down keys to retrieve the commands you previously typed in. >>save filename.mat (This command will save all current values of working variables, such as A, b, C and x in previous demostration, into the filename.mat.) >>load filename.mat (It retrieves the working variables when you need them in a later time. The variable names are also the same as the time you saved.) Please notice the difference between save and diary commands. Warning: Diary files cannot be reloaded into MATLAB using load command. Edit your record file, in MATLAB click the menu File , Open M-file , and then give the file name (a:pract.txt, for example).

Update e:\student\ma237\matlab\orient.doc

by

7/6/2013

ORENTATION OF MATLAB

page-3

An M-file is a sequence of MATLAB commands. In this session, we will learn how to make an Mfile, edit it, and run it step by step.

1. Access to MATLAB.

2. To open a new file, click File, New, M-file. We are in Matlab editor, give a file name, say a:solve.M (note that the file extension has to be .M). (You may use any editor to edit an M-file. It is not necessary to edit your M-file in the LAB; in fact you can edit your file from your PC, as long as the file namewith an extension .M) Note that again, you can have .M file before entering MATLAB. 3. In the file we type A=[1 1 1 1; 2 4 8 16; 3 9 27 81; 4 16 64 256]; b=[1;9;36;100]; C=[A, b]; Cech=rref( C ) x=Cech(:, 5) % (this gives the solution)

4. Save the file by pulling down the file menu and select SAVE AS then give a file name for the

file.

5. Go back to MATLAB screen by clicking the MATLAB screen, or X out the editor screen.

6. Execute the M-file by typing >> solve <Enter> 7. Let us make the following changes: the M-file solve.m has an input A and b and an output x. It contains the commands. function x=solve(A,b) % x is the solution of Ax=b C=[A,b]; Cech=rref( C ); [m,n]=size( C); x=Cech(:,n); We then save it again before returning to MATLAB. 8. To execute the M-file in MATLAB, we have to prepare the matrix A and vector b. >>A=[1 1 1 1; 2 4 8 16; 3 9 27 81; 4 16 64 256]; >>b=[1;9;36;100]; >> x=solve(A,b) >> help solve % it prints the comments lines between the function and the first command. As an exercise, try to create an M-file called prct2.m that will perform the following: (1) Enter matrices A=[1,2; 2,3], B=[-3, 2; 1, 2], C=[1,0,-2;0,1,1], and D=[3,1;1,2;1,1] (2) Compute A*B, B+5*A, A*C, C*D, D*C, A^2 (A squared), A^5 (A raised to the 5 th power).

Update e:\student\ma237\matlab\orient.doc

by

7/6/2013

- ADVANCED NOISE and Vibration AnalysisUploaded byMuralidharan Shanmugam
- Insilico Desigh of Bio-reactorsUploaded bymycatalysts
- Machine Vision Toolbox for MATLAB.pdfUploaded byAnderson Henrique
- Matlab IntroductionUploaded byPramote Nontarak
- A Quicstart guide to MATLAB GUI k Start Guide to MATLAB GUI for Controlling Arduino Create Graphical User Interface and Command Arduino in Few Hours. - Magesh JayakumarUploaded byAhmad Reza Atef
- MATLAB Robotics toolkitUploaded byIsmael Minchala Avila
- Ode SolversUploaded byMhamed Hammoudi
- Basic Simulink Tutorial 012005Uploaded byDustin White
- 02 - Quantitative Security Analysis - Master - Matlab WebUploaded byfahdly
- MATLAB Cheat Sheet2Uploaded byShaukat Ali Shah
- TUTORIAL Computer and Geosciences PotensoftUploaded bydiegaonovais
- The Automatic Control Telelab- A User-Friendly Interface for Distance LearningUploaded byRobson Soares de Paula
- Attention-From-Motion: A Factorization Approach for Detecting Attention Objects in MotionUploaded byHU YIQUN
- Linear Algebra and Numerical AnalysisUploaded byDinesh Reddy
- Tutorial 2Uploaded byROBERT
- Image Processing PPTUploaded byOmKumarSahoo
- Introduction to Matlab.pptUploaded byreddy naveen
- Fdi 2009 MatlabUploaded byMohammad Iqbal Mahamad Amir
- 50gSolving Linear Systems Using MatricesUploaded byYrvin Escorihuela
- Matlab Tut BasicUploaded byAndry Belleh
- Fie2007 MatlabUploaded bytamnguyen2884
- Blah AUploaded byMINESY
- 05409651Uploaded byChetan Mathapati
- L2-1-2Uploaded byAhmed Ahmed
- Primer on Solving Linear EquationsUploaded byabs4everonline
- MATLAB Workshop Lecture 2Uploaded byMuhammad Waqas
- Ox Learn ManualUploaded byrimalisaac
- PRJ1_LineParameters_MERR123-2017B.pdfUploaded bynegritilloomar
- ManualUploaded byKandlakuntaBhargava
- MAT223_Mid2_2010WUploaded byexamkiller

- DetailsUploaded byveda
- Bloomberg India Banks HDFC Case StudyUploaded byHaritika Chhatwal
- GDS.pdfUploaded byRose Widanti
- 7107cplUploaded bybluefaith
- Usb4000 Oem Data SheetUploaded byDaniel Escalante Guzman
- RSNLive17 Load Monitoring Workshop SlidesUploaded byjdan
- keralaUploaded bysiddharth
- Isotc213wg17n0040rev4 Global TpsUploaded bySrujana Kandagatla
- Technical Tips for (Dry) Arthroscopic Reduction and Internal Fixation of Distal Radius FracturesUploaded byComunicación Piñal
- FCPS Writing Center Proposal 12.12.13lUploaded byaustinmj
- Acute Coronary Syndromes - M. Brizzio (Intech, 2012) WW.pdfUploaded byFamilia Nițulescu
- 2010 en Marine Catalog WebastoUploaded byPablo Posada
- Collections 2 - AnswersUploaded byanand.pasunoori
- 89030803-API-CODESUploaded byRomoex R Rock
- gfgfgfUploaded byMuhammad Farid Ab Rahim
- Phonological Awareness is the Understanding of Different Ways That Oral Language Can Be Divided Into Small Components and ManipulatedUploaded byPalakshVismay
- 15280UnisaCBMRegistrationFormUploaded byduch2020
- 0610_w10_qp_11Uploaded byMohammed MaGdy
- Douglas Spencer - Architectural DeleuzismUploaded byRoss Wolfe
- Infosys case analysisUploaded byUmesh Sonawane
- Word FormationUploaded byDiana Iza Burzo
- Bio Control LectureUploaded bydars23
- Purchase Order ManagementUploaded bynaveenraj_a
- PAFile BSC ParametersUploaded byImran Ali
- Neuro ConstructivismUploaded bypepehux
- Branded orUploaded byPriya Gupta
- Essay RubricUploaded byrachaelmcgaha
- Sri LankaUploaded byveeba
- Castells_2000_Materials for an Exploratory Theory of the Network SocietyUploaded bymiyar
- The Three Dimensions of Universal Medicare in CanadaUploaded byNavin Gamage