ENGINEERING COURSES FOR UNDERGRADUATE STUDENTS

LECTURES & APPLICATIONS
 
HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 Dealing with Matrices

Go down 
AuthorMessage
Eng.Saeed Almalowi



Posts : 38
Join date : 2009-10-27
Location : UNITED STATE OF AMERICA, STATE COLLEGE,PA

PostSubject: 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 get

2 7
4 3

as 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 with

c(1,Smile

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 doing

x = A\b

after you define A and b. The \ represents "left division"
Back to top Go down
View user profile http://www.aalhameed1.net
 
Dealing with Matrices
Back to top 
Page 1 of 1
 Similar topics
-
» Re: Guidelines for Dealing with Fraud and Corruption
» Two Envelop Sytem
» Paranoia and/ or guilt
» I'm so sick and tired of people not getting it!
» Spring's here- and so are allergies.. and migraines :(

Permissions in this forum:You cannot reply to topics in this forum
ENGINEERING COURSES FOR UNDERGRADUATE STUDENTS :: ENGINEERING PROGRAMS/SOFT WARE :: MATLAB PROGRAM FORUM-
Jump to: