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 6232441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:07:05+00:00 2026-05-24T10:07:05+00:00

I try to calculate a line that can fit given several points with 2-d

  • 0

I try to calculate a line that can fit given several points with 2-d coordinate in MATLAB. But the result is not I expected. There may be something I understand wrong. Can anyone help me out? Thanks a lot. The code is as follows:

ptsAroundVCP_L=[180,188;177,191;174,191;171,191;168,188;] % points with 2-d coordinate 
curLinePar_L=polyfit(ptsAroundVCP_L(:,2),ptsAroundVCP_L(:,1),1); % parameter of the fitted line

%% begin to plot
plotx=1:256;    
figure(11);hold on;
plot(ptsAroundVCP_L(:,2),ptsAroundVCP_L(:,1),'sb');    
ploty_L=polyval(curLinePar_L,plotx);
plot(plotx,ploty_L,'r');
hold off;

The output is shown as follows. But what I expected is that the fitted line should go vertically in this case. I think there is something wrong with the line fitting.
enter image description here

  • 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-24T10:07:06+00:00Added an answer on May 24, 2026 at 10:07 am

    It is impossible to fit any reasonable polynomial to this data as given:

        X     Y
       188   180
       191   177
       191   174
       191   171
       188   168
    

    Take the transpose and you will get something reasonable:

    ptsAroundVCP_L=[180,188;177,191;174,191;171,191;168,188;]
    
    y = ptsAroundVCP_L(:,2);
    x = ptsAroundVCP_L(:,1);
    
    p = polyfit(x, y, 2);
    
    plotx= linspace(150, 200, 101);
    
    figure(11);
    
    plot(x, y, 'sb');    
    hold on
    
    ploty = polyval(p, plotx);
    plot(plotx, ploty, '-');
    hold off;
    

    enter image description here

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

Sidebar

Related Questions

Given a coordinate (lat, long), I am trying to calculate a square bounding box
I am new at using MIPS and I try to calculate Hamming distance. However
try { JSONArray jArray = new JSONArray(result); for(int i=0;i<jArray.length();i++) { JSONObject json_data = jArray.getJSONObject(i);
I read the manual that filesize() is able to calculate file size from remote
I am confused with the technical jargon that was involved in this question: Given
how can I get calculate with image height and width? I am trying to
I have some ajax onclick stuff that updates this line when the value is
i want to calculate how many pixels there are between 2 points on my
Guys, sorry for the basic question. I try to find out but I still
I wrote a Java program that can execute another Java program during runtime. The

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.