Creating scalar and array variables

Assignment Help Other Engineering
Reference no: EM132334525

Modeling & Simulation Portfolio Assignment -

Task 1 - Creating scalar and array variables, Solving equations, Matrix Operations

Q1) Let

815_figure.png

a) Write a command to arrange the element of the vector E in the ascending order.

b) Write a command to return the smallest element of vector E.

c) Write a command to delete 2nd column from matrix C.

d) Use left division to solve X = A-1B.

Q2) Use either solve or fzero, as appropriate, to solve the following equations:

(a) 8x + 3 = 0 (exact solution)

(b) 8x + 3 = 0 (numerical solution to 15 places)

(c) x3 + px + q = 0 (Solve for x in terms of p and q)

(d) ex = 8x - 4 (all real solutions). It helps to draw a picture first.

Task 2 - 2-D Plots, Getting Help

Q1) Use plot and/or ezplot, as appropriate, to graph following functions:

(a) y = x3 - x for -4 ≤ x ≤ 4.

(b) y = sin(1/x2) for -2 ≤ x ≤ 2. Try this one with both plot and ezplot. Are both results "correct"? (If you use plot, be sure to plot enough points.)

(c) y = tan(x/2) for -π ≤ x ≤ π,-10 ≤ y ≤ 10 (Hint: First draw the plot; then use axis.)

Q2) Help and documentation

Get help on the MATLAB function fprintf by using Type help fprintf command in the command window, or The Help Browser.

Explain the difference of the following fprintf commands and show their outputs, respectively:

Value = 123.4567e2;

fprintf('Value = %e\n', Value);

fprintf('Value = %f\n', Value);

fprintf('Value = %g\n', Value);

fprintf('Value = %12.4f\n', Value);

Task 3 - Script files, Program design with conditional statements and loops

Q1) Script files and input/output commands

Create a script file named task3_1.m and write the following sequence of commands (also called program) in this script:

radius = input('Enter the circle radius:\n');

Area = pi*radius^2;

Perimeter = 2*pi*radius;

fprintf('The area is %f \n', Area);

disp(['The perimeter is ' num2str(Perimeter)]);

Run the script and explain what do the sets of statement do? Take a screenshot of your command window to show one example how the program works.

Q2) Use if-elseif-else-end to calculate students' grade

Write a program in a script file named task3_2.m to read a numerical mark and then assign a letter grade to it according to the following table:

Mark

Letter grade

80 ≤ mark ≤ 100

High Distinction

70 ≤ marsk < 80

Distinction

60 ≤ mark < 70

Credit

50 ≤ marks < 60

Pass

0 ≤ mark < 50

Fail

mark < 0 or mark > 100  

Invalid

The program asks the student to enter the numerical mark in command window; and then display the letter grade in command window.

For example: After running the program, a student could enter his mark in the command window. Then, the student's letter grade will be returned immediately.

Q3) Use for-end loop to calculate numerical equation

Write a program in a script file named task3_3.m to calculate the sum of the first n terms of the series:

k=1n(-1)kk2/1.2(2k+1)

The program asks the user to enter the number of n in command window; and then display the result in command window.

Run the script file for n = 4 and n = 20, respectively, and show the result in the command window like the following format:

>> task3_2

The result for n = 8 is 1.322298.

Q4) Use while-end, if-end, break commands to solve the numerical problem

Write a script file named task3_4.m that sums a sequence of random numbers (use randn) until the sum is greater than 10. If the random number generated is greater than 3, exit the loop immediately without doing the sum.

Display the sum of the random numbers and the last random number generated in command window when the program terminates. The display format may like this: >> task3_4.m

The sum of the random numbers is: 10.571232

The last random number generated is: 1.618112

Task 4 - Solving Engineering application with MATLAB

Q1) As shown in figure, a series RL circuit as shown acts as a low-pass filter.

244_figure1.png

i) Write down the transfer function for the low pass filter.

ii) Draw the simulink model for the low pass filter in part i (assume cut off frequency, fc = 100Hz and amplitude for the input signal is 10V)

iii) Draw the output waveforms when input signal (Vi) frequency is equal to 20Hz and 120Hz.

Q2) WikiPedia defines "Terminal Velocity" as follows: In fluid dynamics, an object is moving at its terminal velocity if its speed is constant due to the opposing force exerted by the fluid through which it is moving. A free-falling object achieves its terminal velocity when the downward force of gravity (FG) equals the buoyancy/resistance force of drag (Fd). This causes the net force on the object to be zero, resulting in an acceleration of zero. Mathematically, the terminal velocity of an object falling through air is given by

Vt = √(2mg/ρACd)

Where Vt = terminal velocity in m/s,

m = mass of the falling object in kg,

g = acceleration due to gravity = 9.8067 m/s,

Cd = drag coefficient, usually = ∼ 0.5

ρ = density of the fluid through which the object is falling, for air this is = 1.29 kg/m3

A = frontal area of the object

Write a MATLAB script file (call it terminal_velocity.m) that does the following: The first line in the script file (with your information filled in) should be:

  • Use a basic for loop to repeat the following code twice
  • Ask the user to enter the object's mass in kg.
  • Ask the user to enter the object's frontal area in m2.
  • Calculate the object's terminal velocity.
  • Use appropriate comment statements in your script file.
  • Print out the result using the fprintf command.

Clearly write down your MATLAB code and show the output you get.

Reference no: EM132334525

Questions Cloud

Please predict the iphone demand in next 5 years : Please explain future inventions inspired by the iPhone X. Also, please predict the iPhone demand in next 5 years.
Common costs associated with unethical behavior : In what ways do unethical behaviors increase organizational costs? What are some of the common costs associated with unethical behavior?
Sequence of moves make strategic sense for pfizer : Does this sequence of moves make strategic sense for Pfizer? For Warner lambert?
Discussion of value of human life vs tragedy of group think : Describe the process of Group Think or Othering or Scapegoating based solely on membership in a group and the stereotype used to defend the Dominant Group
Creating scalar and array variables : Modeling & Simulation Portfolio Assignment - Creating scalar and array variables, Solving equations, Matrix Operations
Understanding of personal-organizational needs : In brief, describe the theory and how it has increased our understanding of personal and organizational needs and satisfaction.
Why given approach is the best one to provide information : Explain why this approach is the best one to provide information for your area of interest. Create a PICOT/PICo question using the PICOT/PICo format.
What were some of the questions asked : For the initial post, address the following: What were some of the questions asked? If you have not been on an interview, look up three questions an interviewer
What routines and rituals do you observe : Describe a relationship story that you tell with this person or about this person. What personal idioms do you use? What routines and rituals do you observe?

Reviews

Write a Review

Other Engineering Questions & Answers

  Characterization technology for nanomaterials

Calculate the reciprocal lattice of the body-centred cubic and Show that the reciprocal of the face-centred cubic (fcc) structure is itself a bcc structure.

  Calculate the gasoline savings

How much gasoline do vehicles with the following fuel efficiencies consume in one year? Calculate the gasoline savings, in gallons per year, created by the following two options. Show all your work, and draw boxes around your answers.

  Design and modelling of adsorption chromatography

Design and modelling of adsorption chromatography based on isotherm data

  Application of mechatronics engineering

Write an essay on Application of Mechatronics Engineering

  Growth chracteristics of the organism

To examine the relationship between fermenter design and operating conditions, oxygen transfer capability and microbial growth.

  Block diagram, system performance and responses

Questions based on Block Diagram, System Performance and Responses.

  Explain the difference in a technical performance measure

good understanding of Mil-Std-499 and Mil-Std-499A

  Electrode impedances

How did this procedure affect the signal observed from the electrode and the electrode impedances?

  Write a report on environmental companies

Write a report on environmental companies

  Scanning electron microscopy

Prepare a schematic diagram below of the major parts of the SEM

  Design a pumping and piping system

creating the pumping and piping system to supply cool water to the condenser

  A repulsive potential energy should be a positive one

Using the data provided on the webvista site in the file marked vdw.txt, try to develop a mathematical equation for the vdW potential we discussed in class, U(x), that best fits the data

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