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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:28:25+00:00 2026-06-08T17:28:25+00:00

enter image description hereI don’t know how choose the lb and ub for lsqcurvefit

  • 0

enter image description hereI don’t know how choose the lb and ub for lsqcurvefit in MATLAB , as well as x0, to fit my function to data, I mean I have some output but they are not correct,

Here is my data:

xdata= [22.8700000000000;7.92000000000000;3.45000000000000;1.78000000000000;
        1.57000000000000;6.41000000000000;12.9000000000000;1.82000000000000;
        1.86000000000000;3.71000000000000;12.0900000000000;15.9900000000000;
        18.9600000000000;23.1500000000000;23.4500000000000;24.8200000000000;
        25.0700000000000;13.2800000000000];
ydata= [8.44300000000000;7.92100000000000;7.64600000000000;7.51600000000000;
        7.47100000000000;7.82100000000000;8.03200000000000;7.76200000000000;
        7.77400000000000;7.87800000000000;8.07000000000000;8.26000000000000;
        8.40000000000000;8.52000000000000;8.52000000000000;8.57000000000000;
        8.58000000000000;8.03200000000000];

and then I will have myfunc in a separate m file:

 function F = myfun(x,xdata)
  F=x(1)*(1-x(2)^2)./((1+x(2)^2+2*x(2)*cosd(xdata)).^1.5);

I have x(1) and x(2), unknown which I like to estimate after fitting to my data, and I know that k x(2) will not be a negative value.

So I set lsqcurvefit like this:

[x, resnorm]=lsqcurvefit(@myfun,[-0.5:0.5], xdata, ydata, 0, 1.5, options)

And this is the result:

x = 1.5000 -0.4945
resnorm = 52.1739

which shows a negative value for x(2)!

could you please help me?

Thanks a lot for answer my question, and now after the command calculated the x and resnorm, I use the results in my function it means that I used x(1)=92.8054 x(2)=0.7427

so;

F=92.8054*(1-(0.7427)^2)./((1-0.7427)^2+2*(0.7427)*cosd(xdata)).^1.5;

now I have vector F , when I plot my data and results , plot(xdata, ydata, ‘o’, xdata, F, ‘*’)

I don’t why the range of axis y is so different! maybe I need to add x(3) to my function.

I attached the figure.enter image description here

enter image description here

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-06-08T17:28:26+00:00Added an answer on June 8, 2026 at 5:28 pm

    Your upper and lower boundaries must be vectors with the same number of elements as what you are trying to estimate, in your case x.

    So for example if you want x(1) to be unbounded and x(2) to be between 0 and 1.5 then try

    [x, resnorm]=lsqcurvefit(@myfun,[-0.5:0.5], xdata, ydata, [-inf, 0], [inf, 1.5], options)
    

    To calculate F use your objective function you have already created:

    F = myfun(x, xdata) and then plot it the way you already have. In your comment below you have switch a + to a - , this is why your graphs aren’t aligning.

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

Sidebar

Related Questions

![enter image description here][1]On my two demo and screenshot, you can understand that so
Gradient with transparency![enter image description here][1] I wanted to apply transparent multicolor gradient at
![enter image description here][1]i am developing the Android XML file .in my main XML
![enter image description here][1]I have a few of reports in SQL Server Reporting Services
![enter image description here][1] I want to make a tab layout application, in which
I have an NSArray that looks like this: ![enter image description here][1] I need
I have a textbox where user will enter the url of the image :
I've made some image validation. The user has to enter the code from the
I try to implement the animation: when you enter iPhone Gallery, press the image,
so i continue from this question YouTube: get youtube title+ image+description like facebook `

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.