ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 8.00

lastname_dampsineoutline

  1. The "if" construct allows the user to choose among program options.  For this problem, you will write a program that will allow the user to select the desired type of damped sine.  You will first outline the code (lastname_dampsineoutline_01#) based on the instructions below - include the complete preamble with definition of variables.  This outline, without executable code, will be turned in as part of the deliverables.  This outline will be similar to outlines that have been given to you previously.  Then re-save your outline under the name lastname_dampsine_01# and write the code.  Again, both the outline and the code are deliverables.
  • Start your code with the commands:  clear all,close all.  Then use an fprintf command to display your name and lab time with one blank line above and one below. 
  • You will write code that will allow the user to pick the desired damping type, using "ginput", by clicking on the name of the damping type in a graph.  You will want to study Lecture 6, Slide 10 carefully.  The steps involved are as follows:
    • Open figure(1) - (see figure(1) below).  Issue an axis command, 4 text commands, and title to replicate figure(1).  Use the default font size.
    • Issue a single ginput command.  The y coordinate of the output of ginput will be used in your "if" construct to control the damping type.  Make the y coordinate (one of the outputs of ginput) an integer using the "round" command; e.g., (yout).
    • Note:  you have created figure(1) and used ginput to allow the user to select the damping type - you are done with figure(1).
  • Open figure(2), subplot(2,1,1) - (see figures below).  In this subplot, replicate figure(1) only with the chosen damping type in font size 20 and with the title as shown.  This will require the use of an "if" construct.
  • Make the independent variable, x, run from 5pi to 15pi in 0.1 steps
  • Create a character array, dampname, using the "char" command with 4 rows containing the strings: 'Constant', 'Exponential', 'Linear', and 'Quadratic' (note that constant damping is basically no damping with the damping coefficient set to 1)
  • Now use the "if" construct to set the damping coefficient, d, and calculate the appropriate damping function - pick a reasonable name for the damping function:
    • Constant Damping:      d                 where d = 1
    • Exponential:      exp(d(x-5pi))     where d = -0.1
    • Linear:              d(x-5pi)+1          where d = -0.03
    • Quadratic:     d(x^-2)              where d = 1
  • After the "if" construct, calculate the damped sine by multiplying, on an element by element basis, your damping function by sin(x).
  • Plot in figure(2), subplot(2,1,2):
    • In a single plot command, plot:  1) the damped sine vs x (solid black line), 2) the damping function vs x (solid red line) and 3) minus the damping function vs x (solid red line).  Plotting plus and minus the damping function will show the damping envelope superimposed on the damped sine.  See figures below.
    • Use the "sprintf" command to make the title as shown in the graph below.  The type of damping is displayed by sprintf by using the %s format to display the appropriate row of the character array dampname.  To avoid extra spaces, use the "deblank" command on dampname within the sprintf statement (see Lecture 6 Slides 4 - 6).
    • Add x and y axis labels also as shown
    • Add a legend in the upper right corner of the graph (as shown) where the "strcat" command is used to stick the appropriate row of dampname together with the word "Damping".
  • Note that the user-selected damping type (resulting in a y-output from ginput of 1, 2, 3, or 4) is used in your code to specify:  the damping coefficient, the type of damping function, and the row of the dampname array.
  • Run your code 4 times so that you can select each type of damped sine.  An example graph for each type of damping is shown below. 

Answers

(11)
Status NEW Posted 22 May 2017 04:05 AM My Price 8.00

-----------

Not Rated(0)