Create two vectors of length ten of your choice

Assignment Help MATLAB Programming
Reference no: EM131270210

Assignment

1. Revisiting MATLAB anonymous functions and basic logic operations.

a) Use both "polyval" and an anonymous function to calculate the following:

i. 4??4 + 2??2 + ?? - 19 at x = 1,5,10,15
ii. ??2 - 5 at x = 1,3,12,20
iii. 5??3 + 36?? + 8 at x = -5,-1,3,8

b) Using basic logic operators, answer the following questions using MATLAB

i. Create two vectors of length 10 of your choice, and label them x and z.
ii. Show, element by element, where x and z are equal.
iii. Show, element by element, where x is greater than z.
iv. Show, element by element, where x is less than or equal to z.
v. Find the elements where x is greater than z.
vi. Find the elements where z is less than or equal to x.
vii. Replace the elements in (vi) with values 10 times their original value in a single operation.

2. User-defined input-output and logical statements.

a) Consider the following function:
?? = e3x^2+(4/5)x + 36?? + 1

It is desired that this function be evaluated for a variety of user-defined values of x. Create a script file/segment of code that will allow the user to neatly and professionally input a scalar OR vector value of x. Evaluate the function at 3 user- selected points as well as a single user-defined vector input. Display the result using disp(). Be sure to include some output text in addition to displaying the function evaluation result.

b) Consider the following function:

?? (??, ??) = x2 + xy - 36?? + xe4x^2 + 9

Allow the user to input values for both x and y as scalars. Only allow the function to evaluate if the value of x is less than or equal to y. If the function is evaluated, display the value of x and y as well as the function evaluation result using a single instruction. If not, show an appropriate error message to the user and do not allow the function to be evaluated. Evaluate your code at the following points:

i. x = 5, y = 5
ii. x = 0.25, y = e3x
iii. x = 0.2, y = √(?? - 0.01)
iv. x = 1, y = 5

c) Consider the multi-variable function given by:

?? (??, ??, ??) = [√(5z2 + xy3) + 5] / (?? + ?? + ??)

allow the user to input scalar values for x,y, and z and include logic that will stop the script and display an error message if the function is singular or would result in an imaginary number for a provided set of x,y,z. If the function is allowed to evaluate, display the entered values of x,y, and z as well as the value of the function using a single instruction. Otherwise, display and error message. Evaluate at the following points (x,y,z):

i. (4,13,15)
ii. (8,-12,0.1)
iii. (0,0,0)
iv. (5,10,15)

d) Consider the case where the input to a program can be either a scalar, vector, a matrix or a combination of these. Write a program that can add, subtract, multiply or divide the input variables. Note that the division portion is not valid for matrices (we use inverses instead) - you will need to incorporate this in your code. Your program should prompt the user for the type of operation to be performed, to enter the two variables and display the results neatly (using fprintf) or the appropriate error message if the code fails to execute. Test your code using at least 7 different combinations of x and y, allowing each to be scalars, matrices of various shapes (not only square) and vectors.

e) Recall, from homework #3, the equation of motion given by:

?? = 1/2 gt2

where g = 9.81 and time is defined in seconds. Allow the user to input the total time in which he/she would like to know the position of the object. Fix your step-size at 0.1 seconds and start your vector at zero (ending at the value of "total time", which should be input as a scalar). Additionally, create a selection structure that allows the user to select which graph to plot - either the position, velocity or acceleration vs. the time vector you create. Plot the position, velocity and acceleration in 3 separate code executions for a total time of 5 seconds.

3. Working with flowcharts and code documentation.

a) Create a flowchart for the following:

i. Question 2(a)
ii. Question 2(b)
iii. Question 2(c)
iv. Question 2(e)

Reference no: EM131270210

Questions Cloud

Find the order quantity : Lugini Watch’s annual demand is 100. It can produce at a rate of 10 watches per month with a $100 setup cost for the production run. Find the order quantity and I max assuming carrying cost is $100 per unit.
Describe the main elements of fisma in the management : From the e-Activity, describe the main elements of FISMA in the management and governance of federal information systems.
Fixed-order quantity versus fixed period quantity system : Find at least one business example of a fixed-order quantity system versus a fixed period quantity system. What are their differences? Which do you think is better and why?
Substitution effect results in the person buying : Assume beer is an inferior good and the price of beer falls, then the substitution effect results in the person buying (less/more) of the good and income effect results in the person buying (less/more) of the good.
Create two vectors of length ten of your choice : Create two vectors of length 10 of your choice, and label them x and z. Show, element by element, where x and z are equal. Show, element by element, where x is greater than z.
Studies the behavior of individuals-groups and organizations : Studies the behavior of individuals, groups, and organizations, when they manage or use scarce resources to achieve goals
What is the cost-minimising combination : If a firm's output is produced according to Q = 4LK, the priceof K is $10, and the price of L is $40, what is the cost-minimising combination of K and L capable of producing 64 units of output? The cost-minimising quantity of K is? The cost-minimi..
How many units of petroleum will be produced : What is the effect on productivity of doubling both the units of labor and the units of capital?- how many units of petroleum will be produced?
How to use minitab to perform hypothesis testing : Review this tutorial on how to use Minitab to perform hypothesis testing - calculates the average length as 31 mm and the standard deviation as 5 mm.

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Design and explain a computer-based simulation model

Design and explain a computer-based simulation model which you will use to estimate the probability that among 25, 50, 75, 100, 500, or 1000 randomly chosen people, at least 2 people share the same birthday.

  Write a matlab script called estimate_e

How does your actual accuracy compare to the relative tolerance you chose - Can you provide the answer as soon as possible and use basic MATLAB concepts to make this program?

  Calculate the bending moment and shearforce diagrams

Matlab code that will calculate the bending moment and shearforce diagrams for the attached file. It must be possible to input lengths,udl values fro each element and the programme must calculate the reaction forces at A,B,C

  An efficient human identification using gait analysis

An Efficient Human Identification Using Gait Analysis, Apply specific approach for Pattern Recognition,Implement this approach in MATLAB,Compare and discuss the results with others.

  Estimation of the rayleigh limit experimentally

Propose a method that would allow estimation of the Rayleigh limit experimentally. By using Matlab implementation of your method, prove (or disprove) that the theoretically derived equation is correct for a rectangular window.

  Develop a simulation program

Develop a simulation program

  Evaluate the average power for the signals

Evaluate the average power for the signals and graph the discrete-time functions. Find and to graph the unit-sequence response of the system

  Find the laplace transform

Use MATLAB and the Symbolic Math Toolbox to find the Laplace transform - (t) = 8t 2cos (3t + 45°)

  Evaluate the function at a range of x values

Write a function file, that accepts values of x as inputs and outputs the value of y when the input is passed through the following function. Evaluate the function at a range of x values from 0 to 1 with 143 elements.

  Develop matlab function for the fixed-point method

Develop your own Matlab function for the Fixed-point method. Use the estimated relative error as your stopping criterion. The first line of your function should be function

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Write the matlab code to set up the vector

Write the MATLAB code to set up the vector y = [2 4 3 6 2] and plot y in a pie chart. Add a legend and title to the pie chart. The legend should contain the following strings: ‘value1', value2', ‘value3', ‘value4', and ‘value5'. The title should b..

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