 ENGINEERING COURSES FOR UNDERGRADUATE STUDENTSLECTURES & APPLICATIONS Home Calendar FAQ Search Memberlist Usergroups Register Log in

 ENGINEERING COURSES FOR UNDERGRADUATE STUDENTS :: ENGINEERING PROGRAMS/SOFT WARE :: MATLAB PROGRAM FORUM Share

Dealing with Matrices AuthorMessage

Posts : 38
Join date : 2009-10-27
Location : UNITED STATE OF AMERICA, STATE COLLEGE,PA  Subject: Dealing with Matrices Thu Oct 29, 2009 6:48 am Once you have a matrix, you can refer to specific elements in it. Matlab indexes matrices by row and column. c(3,1) is the element in the third row, 1st column, which is 4. c(2:3,1:2) gives you the elements in rows 2-3, and columns 1-2, so you get2 74 3as a result. c(1:3,2) gives you the elements in rows 1-3, and the second column, that is, the entire second column. You can shortcut this to:c(:,2)literally telling matlab to use all the rows in the second column, ie, the 2nd column.You can get a whole row of a matrix withc(1, This literally tells matlab to take the first row, all columns.You can also refer to any matrix with only one index. It will use that index to count down the columns. c(5) will give you 7, for example.When you have a matrix or vector (anything with more than one element) you need to do a few things to make sure all of your math does what you want it to. You can add a constant or multiply by a constant normally (const+c, const*c, etc.) If you have data in two matrices that correspond (for example, a time vector and an x position vector that has x values for each point in time), you can add and subtract those normally (it will map each element properly.)To multiply, divide, or raise to a power when you have a matrix or vector that is acting as a set of data points, you need to use.*./.^so that matlab will multiply each element in the matrix instead of trying to do matrix multiplication or division.Of course, it can also treat matrices as actual matrices, so you can solve something like [A]x = b where A is a matrix of coefficients, x is a column vector of the x values you want to find, and b is also a column vector just by doingx = A\bafter you define A and b. The \ represents "left division"    Dealing with Matrices Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum Jump to: Select a forum||--PRODUCTION & MANUFACTURING ENGINEERING|   |--MACHINE ELEMENT DESIGN FORUM|   |--MECHANICAL VIBERATION FORUM|   |--MACHINE DYNAMICS FORUM|   |--STATICS FORUM|   |--DYNAMICS FORUM|   |--FAULT DIOGNASIS FORUM|   |--WORKSHOP FORUM|   |--MANIFACTURING FORUM|   |--LUBERICATION FORUM|   |--SOLID MECHANICS FORUM|   |--INDUSTRIAL ENGINEERING|   |--ENGINEERING MANAGMENT FORUM|   |--ENGINEERING ECONOMY FORUM|   |--MICRO ECONOMY FORUM|   |--STATISTICS & PROBABILITY FORUM|   |--ELECTRICAL ENGINEERING FORUM|   |--FUNDAMENTAL OF ELECTRICAL CIRCUITS FORUM|   |--DIGITAL FORUM|   |--ELCTERICAL POWER FORUM|   |--MECHANICAL ENGINEERING POWER|   |--HEAT TRANSFER FORUM|   |--APPLIED OF HEAT TRANSFER FORUM|   |--MODELING& SIMULATION FORUM|   |--GAS TURBINE FORUM|   |--DESALINATION TECHNOLOGY FORUM|   |--POWER PLANT FORUM|   |--THERMODYNAMICS FORUM|   |--POWER PLANT FORUM|   |--AIR CONDITIONING AND REFRGERATION FORUM|   |--FLUID MECHANICS FORUM|   |--HEAT ENGINE FORUM|   |--ENGINEERING PROGRAMS/SOFT WARE|   |--MATLAB PROGRAM FORUM|   |--MD SOLID PROGRAM FORUM|   |--SOLID WORK FORUM|   |--ENGINEERING EQUATION SOLVER FORUM|   |--LAB VIEW PROGRAM|   |--GENERAL COURSES    |--MATHEMATICS FORUM    |--PHYSICS FORUM    |--ENGLISH FORUM