This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 14:440:127– Introduction to Computers for Engineers Notes for Lecture 06 Rutgers University, Spring 2011 Instructor  Brenda V. Cortez 1 Introduction You have now seen how fundamental programming concepts from C++ translated into MatLab scripting, and have also learned about matrices and how these programming concepts can be ap plied to them. Along with the functions provided by MatLab, you are now equipped with the tools needed to write sophisticated solutions to the mathematical problems you will encounter as an engineer. As you attempt to solve these problems, one of the areas you will probably want to address, is the efficiency of your code, so in these lecture notes, we will cover efficiency . One question you probably have in mind is: why use MatLab? And part of the reason has to do with what you have already seen through your recitation problems, and assignments. The fact that you can apply many MatLab functions to arrays; functions that have been optimized , when applied to arrays. This is the beauty of MatLab. It can manipulate arrays easily and more im portantly, in a very efficient way. Giving us results quickly and accurately. What you will learn in these lecture notes is that using loops is not always the best solution to problems and that in most cases, you can interpret the problem in terms of matrices, use array MatLab functions, and increase the efficiency of your code. Once we have gone over loops and their inefficiency, we will see how we can animate plotting using loops. However, since we will be covering plotting animation, we will need to cover plots very briefly; just so that we can visualize the animations to be demonstrated. These lectures will finalize by looking at how the concept of user defined functions gets trans fered into MatLab terms and how the scope of variables is treated in MatLab. Once this topic is covered, you will have gone over all the concepts that you learned in C++, using MatLab scripting. 2 Review Let’s begin with a review of the most important topics you learned last week. Make sure you read this section in addition to all the new material, because there are always new perspectives, along with new examples, and most importantly further elaboration on the topic at hand. 2.1 Creating Vectors and Matrices A array will always be defined in terms of its rows and its columns , and if an array is of size 1xN (one row, N columns) or Nx1 (N rows, 1 column), then it is called a vector . Any other array can be referred as a matrix. 2 When creating vectors or matrices, you can use commas or simple spaces to separate values in the array. When creating matrices, you must use the semicolon to separate rows. If you don’t need to explicitly defined each element value, then maybe you want to use the colon operator to create the array. Just like you did in C++, you can create an array that increments or decrements ....
View
Full
Document
This note was uploaded on 03/30/2011 for the course ENGINEERIN 127 taught by Professor Finch during the Spring '08 term at Rutgers.
 Spring '08
 Finch

Click to edit the document details