Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 788581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:23:21+00:00 2026-05-14T21:23:21+00:00

I have information of an object being thrown at a parabolic pattern. There are

  • 0

I have information of an object being thrown at a parabolic pattern. There are 30 images in total taken at specific intervals from the start position till the end.

Now I have managed to extract the x,y coordinates of the object being thrown in all 30 images…
I think that using polyfit (or maybe polyval ? ) may help me predict where the object will fall after the first 15 images …

I just want to know, how can polyfit be used with the 30 x,y coordinates I have ?

( I have a loop to extract each image from a mat file 1 row at a time until 30 .. and then plot that image .. so should I use polyfit in the same loop before/after the plot ???

Any ideas ??

Thanks !

EDIT

This is my current code :

load objects.mat
for G=1:30
    x=objects(G,1);
    y=objects(G,2);
    plot(x,y,'0')
    hold on
    drawnow()
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:23:22+00:00Added an answer on May 14, 2026 at 9:23 pm

    Here’s one way you could animate this, using the function POLYFIT to fit a parabola to x and y, the function POLYVAL to evaluate your polynomial at a set of x values, and the SET command to modify your plot objects instead of having to replot them:

    load objects.mat   %# Load the data
    x = objects(:,1);  %# Get the x data
    y = objects(:,2);  %# Get the y data
    N = numel(x);      %# The number of points
    hPoints = plot(x(1),y(1),'r*');       %# Plot first point as a red asterisk,
                                          %#   saving the handle
    hold on;                              %# Add to the plot
    hFitLine = plot(x,nan(N,1),'b-');     %# Initialize the plot for the fit line,
                                          %#   saving the handle and using NaN for
                                          %#   the y values so it doesn't appear yet
    axis([min(x) max(x) min(y) max(y)]);  %# Set the axis limits
    for k = 1:N
      set(hPoints,'XData',x(1:k),'YData',y(1:k));  %# Update the points
      if k >= 15                       %# Plot a fit line starting at k = 15
        p = polyfit(x(1:k),y(1:k),2);  %# Fit a parabola with points 1 through k
        yFit = polyval(p,x);           %# Evaluate the polynomial at all x
        set(hFitLine,'YData',yFit);    %# Update the fit line
      end
      drawnow();    %# Force the plot to refresh
      pause(0.25);  %# Pause for a quarter second
    end
    

    A note on MATLAB graphics…

    Any time a plotting command is issued (like PLOT), then one or more handle graphics objects are created in the current axes. These objects have a “handle”, or a numeric identifier, that acts as a reference to the plot object and which can be used to access and modify the properties of the object. The GET and SET commands can be used to access and modify, respectively, the properties of graphics objects using their handles, which are typically returned as output arguments from the plot commands.

    Each type of handle graphics object has a set of properties. The PLOT command creates a lineseries object with a number of properties which can be found here. For example, the 'XData' property stores the x values of the plotted points, while the 'YData' property stores the y values. You can change the x and y positions of the plotted points by modifying these properties of the lineseries object.

    When animating graphics in MATLAB, it is generally more efficient to create the object first and update its properties during the animation instead of creating, deleting, then recreating the object during the animation. In the code above, a plot object for the individual points is created before the animation loop and the handle for that object is stored in the variable hPoints. A plot object for the parabolic line is also created before the animation loop, and its handle is stored in hFitLine. Then, the SET command is used in the loop to modify these two plot objects.

    Since the parabolic line is intended to be invisible at first, setting the initial y values to be all NaN causes the line to not be rendered (although the object still exists). You could also make the line invisible by setting its 'Visible' property to 'off'.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am parsing information from my server and have all the information being downloaded
Assume I have a RESTful web service, which holds information about an object that
I have a custom object type dependency property that is being populated at runtime.
I have having issues with a storyboard that is complaining about being unfreezable. There
There are a number of issues i'm having, all being related. Some I have
I have a web application that adds contextual information to XmlHttpRequest objects using the
I have objects in a tree structure, I would like to aggregate status information
I have information entered into a text box on an ASP.net 3.5 page. when
I have information stored in a database that I want to use to create
I have information on school athletics, with tables for school, season, cashflow, and cashflow_group.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.