Write a simple computer program to evaluate a function

Assignment Help Computer Engineering
Reference no: EM131198050

CS 109 - C/C ++ Programming for Engineers w. MatLab- Spring 2016 Assignment-

Evaluating a Function of Two Variables Over Ranges of Inputs Using MATLAB

Overall Assignment-

For this assignment you are to write a simple computer program to evaluate a function of 2 variables over a range of input values, using one- and two-dimensional arrays.  This is basically a repeat of HW3, using MATLAB instead of C++, and adding some simple plotting.

The Function-

For this assignment your program is to evaluate the following function for a range of X and Y values:

f(X, Y) = X cos(X)Y sin(Y)

Calculating the X and Y Vectors-

Generating the X and Y vectors will be much simpler using Matlab:

  • For the X vector, ask the user to enter the minimum and maximum values and the change between each step, and then use the colon operator, :, to generate the X vector.
  • For the Y vector, ask the user to enter the minimum and maximum values and the number of values desired, and then use the linspace( ) function to generate the Y vector.

Matrix Multiplication-

In order to generate the desired final product, you will need to do two types of multiplication:

-Element-by-element multiplication requires two matrices (vectors) of the same size, and is performed by the .* multiplication operator.  That will let you calculate X cos(X) and Y sin(Y) as on-dimensional vectors.

Matrix multiplication multiplies out two matrices, and requires that their "inner" dimensions be the same. So if matrix A has rA rows and cA columns (an rA x cA matrix), and matrix B has rB rows and cB columns (rB x cB), then in order to multiply A * B, cA must equal rB, ( and the resulting product will have rA rows and cB columns, i.e. it will be a rA x cB matrix. )

  • Transposing a matrix effectively flips it along its diagonal, converting rows into columns and columns into rows, so an M x N matrix becomes an N x M matrix when transposed. The transpose operator in Matlab is a single quote, e.g. A = A'

Plotting Results-

The simplest way to plot in Matlab is to select the desired variable(s) in the workspace window, and right-click.  This will bring up a menu of plot types appropriate for the selected data from which you can select one.  The command used to generate the plot will be automatically added to the command window, allowing it to be copied and edited for inclusion in a script. (This also tells you what command to look up documentation for to get more information.)

Program Details / PseudoCode-

For this assignment you are to write a simple computer  program to calculate  X cos(X) Y sin(Y) for a range of X and Y values, and to display the results in a table.  Your program should also do some simple analysis on the results.

-Your program should first print out your name and ACCC netID (e.g. jbell), and explain to the user what the program does.  

-For the X input, your program should read in the minimum value of X, the maximum value of X, and the change in X between data points.

-For the Y input, your program should read in the minimum value of Y, the maximum value of Y, and the number of data points desired in the Y direction.

-Once you have read in the necessary input and allocated arrays, fill the x and y vectors using the colon operator and linspace() respectively.

-Then calculate X cos( X ) and Y sin( Y ) using element wise multiplication and a final result using matrix multiplication, as discussed above.

-Once both vectors and the array are filled, print out the results in a form resembling that shown in the sample above. (Don't sweat getting the numbers to exactly line up under one another, but do leave some space between the numbers so they don't run together.)

-Finally use Matlab functions to find or calculate the following, and report their values:

  • The maximum value of f(x, y) over the defined range.
  • The minimum value of f(x, y) over the defined range.
  • The average value of f(x, y) over the defined range.

Attachment:- Assignment.rar

Reference no: EM131198050

Questions Cloud

Compute the amplitude of the strongest two harmonics : If the switching frequency is 10 kHz, compute the amplitude of the strongest two harmonics in the region of 50 kHz.
Do you think that this has changed your own perspective : How do you perceive changes in social stereotypes, issues, and judgments regarding sexualities as potentially impacting changes in friendship, in the relationships, cultural expressions, and understandings of friendships?
Plot the torque-speed and dc current-speed curves : Plot the torque-speed and dc current-speed curves if it is being fed from a three phase bridge in six-step operation, assuming that the dc voltage is 560 V and the frequency is 120 Hz. Neglect harmonics.
Managers will maximize values of firms by making decisions : Managers will maximize the values of firms by making decisions that maximize………. In every single time period, so long as cost and revenue conditions in each period are. When current output has the effect of increasing future costs, the level of outpu..
Write a simple computer program to evaluate a function : CS 109 - C/C ++ Programming for Engineers w. MatLab- Spring 2016 Assignment. For this assignment you are to write a simple computer program to evaluate a function of 2 variables over a range of input values, using one- and two-dimensional arrays.  ..
Which reit types is not likely to own real property : Which of the following REIT types is NOT likely to own real property? Which of the following is likely to occur upon the sale of a REIT-owned property? A hybrid REIT is comprised of what primary classifications of REITs?
Performs curve-fits of all the data : Determines what type of loading has been applied based on which curve-fit is the best - Demonstrates that the chosen curve-fit is the best both graphically and numerically.
Sketch the a-phase line-to-neutral voltage waveform : Consider a three-phase bridge supplying a wye-connected load in which the a- phase, b- phase, and c- phase resistances are 2, 4, and 4 Ω , respectively. Given that the dc supply voltage is 100 V and the control strategy is six-step operation, sket..
What is the demand curve faced by this firm : Oligopolistic models are based on behavioral assumptions. One behavioral assumption associated with differentiated product markets is that price increases will not be matched, but price decreases will be matched. Suppose Firm A controls 50% of the ma..

Reviews

Write a Review

Computer Engineering Questions & Answers

  Questionsteve smith is a restaurant owner who wants to

questionsteve smith is a restaurant owner who wants to expend his 10000 to modernize his restaurant by adapting it more

  Writing a program that creates three instances

Demonstrate the class by writing a program that creates three instances of it. One instance should hold your information, and the other two should hold your friends' or family members' information.

  Define a flowchart and a pseudocode for the program

After designing the class, design a program that creates an object of the class and prompts the user to enter the name, type, and age of his pet. This data must be stored in the object. Use object's accessor methods to retrieve the pet's name, typ..

  Design a shannon-fano code

Design a Shannon-Fano code for the above three-symbol source alphabet shown above and find its code efficiency. Compare it with your answer in part (b)

  Deducing an expression for pp

Utilizing the information above, deduce an expression for the PP, and provide comment on resulting expression. Also, what the ATM services would you utilize in order to obtain the best possible performance?

  Oe of the needs that your client has is a databaseto

one of the needs that your client has is a database.to design a database a database planner should spend a

  Next generation technology grants access based on human

next generation technology grants access based on human attributes?

  Find a maximum-size independent set in g

An independent set of a graph G=(V;E) is a subset V`C= V of vertices such that each edge in E is incident on at most one vertex in V`. The independent-set problem is to find a maximum-size independent set in G.

  Select a security framework explain the framework selected

write a three to five 3-5 page paper in which youselect a security framework describe the framework selected and design

  Create an announcement of the new system roll out

There are five centers with about 650 members and 30 employees in each location. The system will be used by both members and fitness consultants to track participation. The primary purpose is to assist the fitness center in obtaining the competiti..

  Disadvantages of using mobile computing technology

Analyze the advantages and disadvantages of using mobile computing technology to monitor patients. Assess the security concerns with regard to the transmission of personal medical information over wireless networks

  How various cells can be in a computer''s main memory

Suppose a machine has 20GB of storage space available on a hard disk and receives data over a telephone connection at the rate of 14,400 bps. At this rate, how long will it take to fill the available storage space.

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