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

  Name and briefly describe each of these categories

Streaming video can systems can be classified into three categories. Name and briefly describe each of these categories?

  Based on tests of the chevrolet cobalt engineers have

based on tests of the chevrolet cobalt engineers have discovered that miles per gallon in highway driving are normally

  Design a program that calculates the total ticket sales

The manager of a football stadium wants you to write down a program that calculates the total ticket sales after each game. There are four types of tickets box, sidelline, premium and general admission.

  Compute integral of n-order polynomial using simpson''s rule

The user shall be able to define that integration technique they want to use (They should also have the option to run both integration techniques in one execution)

  Why is a firewall usually a good place to terminate a

why is a firewall usually a good place to terminate a virtual private network vpn connection from a remote user? why

  Sum of the odd positions of the list

Write a function that takes a list of integers as argument and returns a pair consisting of the sum of the even positions and the sum of the odd positions of the list.

  How automated accounting software can help management

Summarize the various accounting systems that each firm provides. Be sure to address the following for each firm: a. The various types of accounting systems it sells (e.g., Oracle sells Oracle Financials as well as PeopleSoft financials)

  Write marie program using a loop that multiplies two numbers

Write a MARIE program using a loop that multiplies two positive numbers by using repeated addition. For example, to multiple 3 6, the program would add 3 six times, or 3 + 3 + 3 + 3 + 3 + 3.

  Compute the record size r in bytes

suppose the file is ordered by SSN; calculate the number of blocks it takes to search for a record given its SSN value by doing a binary search.

  Comapre the advantages and disadvantages of using javascript

comapre the advantages and disadvantages of using JavaScript on the client-side. Where JavaScript is blocked or disabled, does that amount to a potentially significant business loss.

  What types of files would be needed

Visit a commercial Web site (e.g., CDnow, Amazon. com). If files were being used to store the data supporting the application, what types of files would be needed? What data would they contain?

  Utilize linked stack class to support an application

Utilize Linked stack class to support an application

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