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 fundamental theorem of calculus states that the de?nite integral of a function may be found from the antiderivative of the function. However, for many functions, it is much eas

Hi, I need help with solving five-1st order ODE which are coupled. I need to plot these as well. Could I please get a quote. Thanks

2)''dbcont'' command for debugging is used to Select one: a. Continue normal code execution from the debug prompt. b. List all breakpoints. c. Execute (step) one or more lines

1. Write a function to threshold your images separating the background from the foreground: Implement the "peakiness" detection algorithm described in class. The output of your

Write a Matlab function that computes y1= tan(x) and y2= sin(x)/cos(x), returns the difference |y1-y2| and prints a message whether the two are equal or not. Test your function for

Implement a MatLab function to calculate y.  The function should take two input arguments 1) A vector of parameters In the above example this would be of length 3, the first

A fence enclosure consists of a rectangle of length L and width 2 R , and a semicircle of radius R , as shown in Figure 1. The enclosure is to be built to have an area of 1600 m

Vectors and Matrices: The Vectors and matrices are used to store sets of values, all of which are similar type. A vector can either be a column vector or a row vector. The mat

The Plot Function: We will begin with a very simple graph of one point using the plot function. The script, plotonepoint, below plots only one point. To do this, at first the

how to obtain matlab coding for the market clearing price