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

  Multimedia write the code in matlab use of publicly code

MultimediA You need to write the code yourself in Matlab Use of publically available code (e.g., from online sources) is not permitted

  Develop a well-structured function

Develop a well-structured function to compute v as a function of t. Then use this function to generate a table of v versus t for t = -5 to 50 at increments of 0.5.

  Design and implement in matlab an algorithm for lcs problem

Find the longest common subsequence of any two sequences of symbols which have no repeated symbol.

  Least squares

For homework consider the points (0,0), (1,2), (2,3), (3,9), ( 4,17), (5,24), (6,37). (1) Use Matlab to find the least squares best fit with a line.  Turn in A, y and c and a plot like the one above.  Also (2) use Matlab to find the least square best..

  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).

  Develop your own matlab function for the fixed-point method

Develop your own Matlab function for the Fixed-point method. Use the approximate relative error as your stopping criterion. The first line of your function should be function [root,froot,ea,iter] = fixedpoint(func,xr,es,maxit)

  F data into matlab using only the textread function?

load the following type of data into mathlab using ONLY the textread funcion? Need to import it and plot it using boxplot.

  Write a script that will prompt the user for the two areas

Write a script that will prompt the user for the two areas in square feet, and will print whether the velocity at the second point increases, decreases, or remains the same as the first point.

  Plot the pressure surface versus latitude and longitude

Plot the pressure surface versus latitude and longitude as a surface plot

  Which degree do you think best represents the data

Write a Matlab script to try fitting a 1st, 2nd, and 3rd degree polynomial to the dataset described by volume of water vs. volume of ice. Use subplot to draw all three

  Develop a routine to integrate the governing equations

Develop a routine to integrate the governing equations from the left end to the right end using generalized trapezoidal rule to do the integration numerically.

  Calculate and finalize using matlab

Estimate the rate of heat loss by breathing in kcal/hr. Also estimate the rate of water loss in gm/hr. Where A is from your student id number - calculate and finalize using matlab

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