Introduction to vectors, scripts, and functions, MATLAB Programming

In this lab, we study the three concepts. Vector is used to store more than one value into single variable. It is similar to array (other programming language). Script is a collection of statement which is stored into single file name. Function is used to solve the equation and return the result value. It has parameters also.

Sample of Vector:

» x=[-2:5]

x =    -2    -1     0     1     2     3     4     5

Sample of Script:

Impact_v1.m contains,

M=input('Enter the value of m, Mass of the Airplane : ');

V=input('Enter the value of v, Velocity of the Airplane : ');

D=input('Enter the value of Displacement, Displacement of the Airplane : ');

F=(0.5*M*V^2)/D;

disp('The value of the force is printed below : ');

F

How to run the Script?

            » run impact_v1

Sample functions:

function f = ImpactForce(m,v,d)

f = 0.5*m*v^2/d ;

We have learned how to work with vectors and plots. As a result of this lab we computed the impact force for initial velocities from 10m/s to 50m/s as shown in Figure 1. The computations are performed in the ImpactForceVec.m function and the script to set up the calculation is called Impact_v3.m.

297_Introduction to Vectors, Scripts, and Functions.png

Figure 1: The figure shows the impact force on the building for initial speeds ranging from 10m/s to 50m/s. The mass of the aircraft is taken to be 10,000kg, and a stopping distance of 15m is used.

Posted Date: 3/9/2013 1:21:58 AM | Location : United States







Related Discussions:- Introduction to vectors, scripts, and functions, Assignment Help, Ask Question on Introduction to vectors, scripts, and functions, Get Answer, Expert's Help, Introduction to vectors, scripts, and functions Discussions

Write discussion on Introduction to vectors, scripts, and functions
Your posts are moderated
Related Questions
The secant method is an iterative root nding method that is super-linear. The method has the advantage that it is faster than linear methods and does not require knowledge of the


In many applications, including ?nancial mathematics, ?nding zeros of a function f(x) = 0 (4) is paramount. One of the simplest method is the Bisection Method. The bisection

Simulation of a transmission system with a 4-fsk modulation scheme; using non-coherent detection method and an awgn channel. System description: 1. Input: A. Random binary

how to display any words to the edittor

This project carries 50% of your ?nal mark. Please hand in your work to the Mathematical and Physical Sciences School O?ce, no later than 4pm Monday 21st January 2013. Please ?l

write a matlab program to calculate employee salary.

Example of Variables and assignment statements: The expression is computed and then that value is stored in the variable. For illustration, this is the way it would appear in

Variables and Assignment Statements: A variable is used in order to store a value in a MATLAB session, or in a program. The Workspace Window represents variables which have be

what is an error and its types