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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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