Calculating distance using matlab

  • Thread starter Mdhiggenz
  • Start date
  • Tags
    Matlab
In summary, the task was to calculate the distance of a race car during the first 6 seconds of a race, with given time and velocity values. The solution provided used the trapz function, resulting in an answer of 395.5 miles. However, there is uncertainty about the units of distance, as the source material did not specify. It is suggested to clarify the units and convert the velocity values to miles/second before using the trapz function.
  • #1
Mdhiggenz
327
1

Homework Statement


The speed of a race car during the first seven seconds of a race is given by:
t(s)=0,1,2,3,4,5,6
v(mi/h)=0,14,39,69,95,114,129

Calculate the distance of the first 6 seconds.

What I did is q=trapz(t,v)=395.5

answer is 776.6.

Where did I go wrong?

Homework Equations





The Attempt at a Solution

 
Physics news on Phys.org
  • #2
What are the units of distance? Feet, Miles, Furlongs?
 
  • #3
SteamKing said:
What are the units of distance? Feet, Miles, Furlongs?

Looks like miles from the v.

That may be the source of the error. Shouldn't you convert the v values into mi/sec?
 
  • #4
the solution does not specify but I would assume miles.
 
  • #5
Well, if your race car can cover 776.6 miles in 6 seconds, you have quite a machine.

If the solution does not specify units, throw the source material away. It is no good for learning from.
 
  • #6
Mdhiggenz said:
the solution does not specify but I would assume miles.

If the solution doesn't say then why did you write mi/h in the velocity list?

Did you try converting the v values to miles/second and then use the trap function?
 

FAQ: Calculating distance using matlab

How do I calculate the distance between two points using Matlab?

To calculate the distance between two points in Matlab, you can use the dist() function. This function takes in the coordinates of the two points as parameters and returns the distance between them. For example, if you have two points with coordinates (x1, y1) and (x2, y2), you can use the formula dist(x1, y1, x2, y2) to calculate the distance.

2. Can I calculate the distance between multiple points at once using Matlab?

Yes, you can calculate the distance between multiple points at once in Matlab by using the pdist() function. This function takes in an array of coordinates and returns a matrix containing the distances between all the points in the array. The pdist() function also allows you to specify the type of distance metric you want to use, such as Euclidean or Manhattan distance.

3. How can I visualize the distance between points in Matlab?

To visualize the distance between points in Matlab, you can use the scatter() function to plot the points on a graph and then use the line() function to draw lines connecting the points. You can also use the plot() function to create a line plot of the distances.

4. Is there a way to calculate the minimum or maximum distance between points in Matlab?

Yes, you can use the pdist() function with the min() or max() functions to calculate the minimum or maximum distance between points. For example, min(pdist(points)) will return the minimum distance among all the points in the array.

5. How can I calculate the distance between points in a 3D space using Matlab?

To calculate the distance between points in a 3D space in Matlab, you can use the dist() function with three parameters: the x, y, and z coordinates of the two points. This will give you the 3D distance between the two points. You can also use the pdist() function with an array of 3D coordinates to calculate the distances between multiple points in 3D space.

Back
Top