How do you create a new script or function in matlab

Assignment Help MATLAB Programming
Reference no: EM13770940

The input function is a MATLAB built-in function that allows a program to accept user input. For example, if one wanted to ask the user to enter a number between 1 and 5, the MATLAB code would look like:

some_num = input(‘Enter a number between 1 and 5')

This code would ask the user to enter a number between 1 and 5, and store the input number in the some_num variable. You may be wondering what the single quotes are. In MATLAB, single quotes denote a string. A string is a sequence of characters, such as ‘dog', and ‘ate my homework!'. For the purposes of this lab, you can consider a string to simply represent text.

1) Based on the information above, write the MATLAB code to ask the user to enter a velocity in m/s. Be sure to store the input in a variable that has a fitting name.

One can also do element-wise multiplication with vectors and matrices in MATLAB (Hadamard product). It is, however, different syntax than multiplying scalar values. For example, if we wanted to multiply a vector x by the scalar 4 (in other words, scale the vector by 4), we would simply write the code 4 * x. This syntax does not work if we want to multiply x by another vector, say y. In order to do element-wise multiplication for vectors and matrices, we need to add a dot to our mathematical operator. Instead of x * y, we would write the code x .* y. The need for the . next to the operator is only necessary for multiplication and division. Addition and subtraction follows the normal, conventional syntax.

2) You have two Matrices, A and B. Assume that they are the correct dimensions (i.e. Both rows and columns are equal). Write the MATLAB code to do the following.

a) Add A and B

b) Subtract B from A

c) Multiply A and B

d) Divide B by A

e) A Cubed (Hint: remember that A raised to the third power is the same as A times A times A)

3) Scripts and functions (also known by their extension as .m files) are ways of organizing code in units or modules. Use the links below to answer the following questions:

MATLAB scripts and functions

MATLAB creating and running scripts

a) What is the difference between a script and function?

b) How do you create a new script or function in MATLAB?

c) List two ways to run a script in MATLAB

Reference no: EM13770940

Questions Cloud

Write an article on optimisation of storage for solar plants : Write an article on the following topic- Optimisation of Storage for Concentrated Solar Power Plants and Developmental mechanism for the resistance change effect in perovskite oxide.
Combustion of hydrocarbons in ideal dry air : Generate algebraic expressions for coefficients a, b, c, d, e, and f as functions of each other and of (known) x and y as far as possible. In particular, provide equations for b, c, d, and f as functions of x, y, a, and e.
What is marketing and describe the four ps of marketing : The Marketing Mix. Explain what is Marketing. Describe the four P's of Marketing. Choose any product you wish and give examples of the four P's and how they entice the consumer to buy.
Ethical principle of last resort : Pursuant to the Ethical Principle of Last Resort, one is morally obligated to act, to aid, to rescue if what conditions are present
How do you create a new script or function in matlab : What is the difference between a script and function. How do you create a new script or function in MATLAB
What is the yearly cost to the american taxpayer : What is the yearly cost to the American taxpayer and what percent of the total federal budget is spent on this program relative to other programs?
Write paper on social media in business about bloomingdales : Write a paper on social media in business about Nordstrom or Bloomingdales.
Choose the two segments of the general environment : Choose the two segments of the general environment that would rank highest in their influence on the corporation you chose. Assess how these segments affect the corporation you chose and the industry in which it operates.
Write essay on effects of twitter and instagram on teenagers : Write an essay on The Effects of Twitter and Instagram on Teenagers. Demonstrate Critical Thinking about the role of audience in shaping your argument.

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Table of hurricane categories and associated wind speeds

Review the following table of Hurricane categories and associated wind speeds (miles per hour) and storm surge levels (feet above normal).

  Function that takes as input parameters a function

Define a function that takes as input parameters a function handle f, start, and end values a and b, and a number of steps n. The function should compute and return the average value of f over the range a to b.

  Hi i attached the instructions would you guys do it by 50

i attached the instructions. ltbrgt ltbrgtwould you guys do it by 50 dollars ? ltbrgt ltbrgtit is due this friday

  With a time step of h 01 in each case use starting values

dydt yt- yt2 1 le t le 2 y1 1approximate the solution to the above initial value problem usinga 2-step

  In matlab to illustrate the different format specifiers

1.) Write a program in matlab to illustrate the different format specifiers that can be used for obtaining formatted output.

  Blood declines due to metabolic processes

Find an expression for the half-life in terms of k, and obtain a plot of the half-life versus k for the indicated range.

  Fingerprint watermarking techniques

Need to investigate the best method to embed watermark image into fingerprint image.

  Biologically inspired method

Biological ly Inspired Methods + Ma tlab Assignmen t,  Define a problem of your choice which can be tackled by Biologically Inspired Methods. The problem must satisfy the following requirements

  Travelling salesman problem involves

The Travelling Salesman problem involves a salesman who has to visit a number of cities in a single closed tour. The salesman always starts and ends the tour in his home city and visits each other city on the tour exactly once.

  Perform gauss-jordan elimination

Write a matlab function to perform gauss-jordan elimination with pivoting. Modify the pivoting so that it is using the row with the highest absolute value rather than the first non-zero row.

  Display the miles per pound of fuel m against the air speed

fuel consumption of an aircraft in short flight is given by the functionm -0.000653 a2 0.127 a - 5.01where m is the

  Write a simple program that stores the high temperatures

A meteorological company wants you to write a simple program that stores the high temperatures and low temperates for each of the months of the year. After consulting with trusted programming partners, you come up with a great idea

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