Introduction to vectors, scripts, and functions, MATLAB Programming

Assignment Help:

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.


Related Discussions:- Introduction to vectors, scripts, and functions

Load from file and plot data, Example: Load from File and Plot Data: A...

Example: Load from File and Plot Data: As illustration, a file known as timetemp.dat stores two lines of data. The first line is the time of the day, and the next line is the

To change a variable, To change a variable: To change a variable, the ...

To change a variable: To change a variable, the other assignment statement can be used that assigns the value of a different expression to it. Consider, for illustration, the

Convolution, Perform the convolution of following sequences (a) x[n] = [1 2...

Perform the convolution of following sequences (a) x[n] = [1 2 3], N1 = 1 and h[n] = [1 - 1], N2 = 1 (b) x[n] = [1 2 3], N1 = 2 and h[n] = [1 - 1], N2 = 1 (c) x[n] = [1 2 3], N1 =

Pre- dicting and plotting., You will need to implement at least two Matlab...

You will need to implement at least two Matlab functions: HW3main.m and svmTrain.m. The implementation details are as follows: function [alpha] = svmTrain(X,T,kernel,C,sigma) %

Create a function to generate a sinusoidal signal, Create a function using ...

Create a function using mat lab to generate a sinusoidal signal. The parameters of the signal should have an Amplitude = 100, frequency = 100Hz, initial phase = 0, sample rate = 50

Physics, how do you make a program for a parachute man falling to determine...

how do you make a program for a parachute man falling to determine his terminal velocity, having in consideration the drag force (cv^2). I have the formula to be v(i+1)=v(i)*delta(

CPM AND PERT, ACTIVITIES OF A PROJECT 1-2 1-3 1-4 1-5 2-6 3-6 3-7 4-7 5-7 7...

ACTIVITIES OF A PROJECT 1-2 1-3 1-4 1-5 2-6 3-6 3-7 4-7 5-7 7-6 6-8 7-8 THE COMMPANY LOSES 2,000 FOR EVERY WEEK THE PROJECT LASTS BEYOND 30 WEEKS. fOR EACH OF THE PROPOSALS; ACTIVI

If-else statement, The IF-ELSE Statement: The if statement selects whe...

The IF-ELSE Statement: The if statement selects whether an action is executed or not. Selecting between the two actions, or selecting from numerous actions, is accomplished by

Implement the solution using matlab, a. Develop and submit the simulation d...

a. Develop and submit the simulation described above. b. Provide a screen shot of the outputs of the DispConfig and MCResults functions. c. Notes: • Include the PPConfig f

Option pricing, Barrier Option pricing in Matlab using MC simulation or fin...

Barrier Option pricing in Matlab using MC simulation or finite difference methods

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd