Plotting Maximum Height & Horizontal Distance

In summary, the conversation is about a person trying to solve a problem using a MATLAB script but encountering an error. The problem involves showing the maximum height and horizontal distance traveled by an object thrown at a speed of 10ms-1 at different angles. The equations for distance and height are provided, along with the values for gravity, velocity, and angle. The person shares their code but gets an error related to the use of the keyword "end" and the undefined variable "y." They receive help and the issue is resolved. The conversation ends with a question about the preprocessing steps for accurately extracting the fundamental frequency from a speech signal.
  • #1
roam
1,271
12
I'm trying to solve the following problem using a MATLAB script but I keep getting an error:

Show on the same axes the maximum height and horizontal distance traveled for an object thrown at a speed of 10ms-1 at an angle ranging from 0 to π/2. Equation for distance & height are:

D= v2/g sin(2θ)

h= (v2/2g) sin2θ

g=9.81.

This is my code:

Code:
g=9.81; v=10;
t=pi/2;
D=(v^2/g)*sin(2*t);
h=(v^2/(2*g))*(sin(t)).^2;
end
plot([0:t],D,'b',[0:t],y,'*')
legend('horizontal distance','maximum height')

When I run this code the graph doesn't come up and I get the following error:

? Error: File: Untitled.m Line: 5 Column: 1
Illegal use of reserved keyword "end".

Any help here is very much appreciated. :smile:
 
Physics news on Phys.org
  • #2
There is an "end" but nothing is started e.g. "if, while" etc. Also you did not define variable "y"

Code:
g=9.81; v=10;
t=0:0.1:pi/2;
D=(v^2/g)*sin(2*t);
h=(v^2/(2*g))*(sin(t)).^2;
plot(t,D,'b',t,h,'*')
legend('horizontal distance','maximum height')

This should work...
 
  • #3
Pls help me..
what are the preprocessing steps to be performed on a speech (wav file)signal in order to extract the fundamental frequency accurately?
 
  • #4
Thank you so much Trambolin, it worked! :smile:
 

1. What is the purpose of plotting maximum height and horizontal distance?

The purpose of plotting maximum height and horizontal distance is to analyze the trajectory of an object that is launched or thrown into the air. This can help in predicting the landing spot of the object and understanding its motion.

2. What factors affect the maximum height and horizontal distance of an object?

The maximum height and horizontal distance of an object are affected by various factors such as the initial velocity, angle of launch, air resistance, and the force of gravity. These factors can either increase or decrease the height and distance of the object.

3. How do you calculate the maximum height and horizontal distance of an object?

The maximum height and horizontal distance of an object can be calculated using mathematical equations such as the projectile motion equations. These equations take into account the initial velocity, angle of launch, and other factors to determine the height and distance of the object at any given time.

4. Can the maximum height and horizontal distance of an object be measured in different units?

Yes, the maximum height and horizontal distance of an object can be measured in different units such as meters, feet, or kilometers. However, it is important to use a consistent unit of measurement for accurate analysis and comparison.

5. How can plotting maximum height and horizontal distance be useful in real-life applications?

Plotting maximum height and horizontal distance can be useful in various real-life applications such as sports, military operations, and space exploration. It can help in predicting the trajectory of a ball in sports, aiming a target in military operations, and launching satellites into orbit in space exploration.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
289
  • Introductory Physics Homework Help
2
Replies
38
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
222
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
939
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
26
Views
2K
  • Introductory Physics Homework Help
Replies
8
Views
1K
Back
Top