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

Built-in functions and help, Built-In Functions and help: There are lo...

Built-In Functions and help: There are lots of built-in functions in a MATLAB. The help command is used to find out what functions MATLAB has, and how to use them. For illustr

Create a matlab script file, Damped free vibrations can be modelled by cons...

Damped free vibrations can be modelled by considering a block of mass m that is attached to a spring and a dashpot as shown. From Newton's second law of motion, the displac

Vector-array multiplication in simulink, Statement of Problem I need to...

Statement of Problem I need to realise vector-array multiplication in Simulink. This has been realised in Matlab but because the process yielding the received signal is in Simu

Exact arithmetic, Run the MATLAB script sum = single(0); term = single(1); ...

Run the MATLAB script sum = single(0); term = single(1); n=1; while sum + term > sum sum = sum+term; n=n+1; term = 1/n; end n Explain what you think it is trying to do. What wou

Printing vectors and matrices, Printing Vectors and Matrices: For vect...

Printing Vectors and Matrices: For vector, if the conversion character and newline character are in the format string, it will print in a column in spite of of whether the vec

Illustrations of if statement, Illustrations of if statement: illustra...

Illustrations of if statement: illustrations of running this script: >> sqrtifexamp Please enter a number: -4.2 The sqrt of 4.2 is 2.0 >> sqrtifexamp Please ent

Implement the physat algorithm, Your task is to implement the PHYSAT algor...

Your task is to implement the PHYSAT algorithm in Matlab to classify the phytoplankton species in the data you have selected. An algorithm demonstrating one solution is provided b

Function functions, Function Functions: The one reason for using funct...

Function Functions: The one reason for using function handles is to be able to pass functions to the other functions-these are known as function functions. For illustration

Determine the ball temperature , In the manufacturing of ball bearings, the...

In the manufacturing of ball bearings, the components, such as the ball, are hardened through a process of heating and then rapid cooling or "quenching" by submersion in an oil or

Extraction, i want to extract an image from its background in matlab..the i...

i want to extract an image from its background in matlab..the image is a binary image

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