Matlab Code:
format short
gg=9.81;
y0=1;
v0=25;
theta0=50*pi/180;
s=10000;
xmin=0;
xmax=60;
r=rand(s,1);
xrand=xmin+(xmax-xmin)*r;
yrand=tan(theta0)*xrand-gg/(2*v0^2*cos(theta0)^2)*xrand.^2+y0;
[ymax,i]=max(yrand);
xmax=xrand(i);
y=@(x)-tan(theta0)*x-gg/((2*v0^2*cos(theta0)^2)*x.^2+y0);
[xmax,hmax]=calc_trajectory(y,0,60)
Output:
xmax =
59.9999
hmax =
-71.5052
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <ctime>
using namespace std;
int main ()
{
srand (time(0));
string operation;
cout << "Using the letters 'o', or 'q',
please indicate if you would like to simulate once, or quit the
program: " << endl;
cin >> operation;
string reservoir_name; // Creating variables for
reservoir
double reservoir_capacity;
double outflow;
double inflow_min;
double inflow_max;
if (operation == "q")
{
cout << "Exiting
program." << endl;
system ("pause");
return 0;
}
while (operation == "o") // Choose
one or multiple simulations.
{
string reservoir_name; // Creating variables for reservoir
function
double reservoir_capacity;
double inflow_min = 0;
double inflow_max = 0;
double inflow_range = inflow_min + inflow_max;
double inflow_difference = inflow_max - inflow_min;
double inflow_threshold = .9 * inflow_range/2; // Math for
acceptable flow threshold.
cout << "What is the name of the reservoir?" <<
endl;
cin.ignore ();
getline (cin,reservoir_name); // Grab whole string for reservoir
name.
cout << "What is the capacity of the reservoir in MAF
(Millions of Acre Feet)?" << endl;
cin >> reservoir_capacity;
cout << "What is the minimum inflow?" << endl;
cin >> inflow_min;
cout << "What is the maximum inflow?" << endl;
cin >> inflow_max;
cout << "What is the required outflow?" << endl;
cin >> outflow;
inflow_range = inflow_min + inflow_max;
inflow_threshold = .9 * inflow_range/2;
cin.ignore ();
if (outflow > inflow_threshold) // Check for unacceptable
outflow levels.
{
cout << "Warning! The outflow is over 90% of the average
inflow. Simulation aborted. Returning to main menu." <<
endl;
}
else
{
const int number_simulations = 10;
double fill_level = 0;
int years = 1;
cout << "Running simulation." << endl;
for (int i = 1; i < number_simulations; i++) // Each year
{
for (years; fill_level < reservoir_capacity; years++ )
{
double r = rand() * 1.0 / RAND_MAX;
double x = inflow_min + inflow_range * r;// SHOULD be between
minimum inflow and maximum inflow.
if (fill_level < 0)
{
fill_level = 0;
}
} // Simulate the change of water level.
cout << years << endl;
}
}
cout << "What would you like to do now?" << endl; //
Saving for later. The menu re-prompt message and code.
cout << "Using the letters 'o', or 'q', please indicate if
you would like to simulate once, or quit the program: " <<
endl;
cin >> operation;
}
system ("pause");
return 0;
}
1. (10 points A Monte Carlo analysis can be used for optimization. For example, the trajectory...
I want Matlab code related to 14.35.
14.35 A Monte Carlo analysis can be used for optimization. For example, the trajectory of a ball can be computed with 2 |(P14.35) x+yo 2 cos20o y=(tan0o)x where y the height (m), Go = the initial angle (radians), the initial velocity (m/s), g 9.81 m/s, and yo vo = 25 m/s, and Oo = 50", determine the maximum height and the corresponding x distance (a) analytically with calcu- lus and (b) numerically with...
C++ please A typical problem encountered in the study of
dynamics is the trajectory problem. In the situation illustrated
below, a projectile is fired from the edge of a cliff with an
initial velocity, Vo , and a firing angle, A. The cliff
has a height, h. It is desired to:
1. determine the distance,
xt, to the target
2. determine the highest
elevation reached, ymax
3. determine the time to reach
the target, tt
4. ...
Please help with this exercise in Matlab
4 The range of an object shot at an angle θ (with respect toxaos), with the initial velocity of Va (in the absence of air resistance), is calculated by the following formula: va , sin(20) Range (0 052) And the trajectory of object is given by where h is the height of the object at each x location and g 9.81 m/s. Using n/8 increment size for the angle and Vo-10 m/s, plot...
Student Name 1. A particle confined to motion along the x axis moves with constant acceleration fromx = 2.0 m to x 8.0 m during a 2.5-s time interval. The velocity of the particle at x - 8.0 m is 2.8 m/s. What is the acceleration during this time interval? 2. The polar coordinates of a point are r=5.50 m and Angle 240°. What are the Cartesian coordinates of this point? 3. On occasion, the notation A= [A, O] will...
cally up from a moving cart. The position of the balls to raph below shows the position of the ball at equal time inter- A ball is fired vertically up from a mo the left of the graph below showst vals, as would be seen by the person on the cart. a. For this person the motion is sym- metric in time so positions on the way down are the same as on the way up, so only one ball...
5:16 lLTE ) Done 1 of 5 Assessment #1 (Kinematics of a Particle) Rectilinear Motion (Straight linc Motion 3. The position of a point during the interval of time from r otor 6 is given by ** * m. (a) What is the maximum velocity during this interval of time, and at what time does it occur? (b) What is the acceleration when the velocity is a maximum? (20 m/s, 0 m/s 3. A test projectile is fired horizontally into...
10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...
summatize the following info and break them into differeng key points. write them in yojr own words
apartus
6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...