Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: index out of bound because numel(x) = 1
Replies: 9   Last Post: Feb 10, 2014 3:05 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
question on Lorenz equation

Posts: 160
Registered: 12/7/04
Re: index out of bound because numel(x) = 1
Posted: Feb 10, 2014 1:59 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Steven Lord" <Steven_Lord@mathworks.com> wrote in message <ldb0jr$t0v$1@newscl01ah.mathworks.com>...
>
> "Prabodh " <newsreader@mathworks.com> wrote in message
> news:ld39a8$ge0$1@newscl01ah.mathworks.com...

> > Hi,
> > I am trying to do least square fit. I have looked at the examples in the
> > Matlab official web site that may be somewhat related to my problem. I
> > found one that may be useful to me and wrote it exactly as it was shown in
> > the Matlab official web site. I have pasted it below: -
> > function F = trial(x,xdata)
> > F = x(1)*exp(x(2)*xdata);

>
> I suspect that you're trying to call LSQCURVEFIT with @trial as the first
> input INSIDE THE TRIAL FUNCTION itself. That is not correct. Your trial.m
> file should contain exactly the above two lines, that's it.
>

> > x =[1 0.2 3 4 5 6 7 8 9 10]; % (This part is not given in the web site. I
> > added it % %after I got the error message. This did not fix the problem.
> > Then I tried giving this % data different name, but it still did not fix
> > the problem.)

>
> The line above is unnecessary. Place the four lines below in a separate
> file:
>

> > xdata =[0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3];
> > ydata =[455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5];
> > x0 = [100; -1] % Starting guess
> > [x,resnorm] = lsqcurvefit(@trial,x0,xdata,ydata);

>
> To execute this example, execute the name of the file containing this code,
> not the trial function.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com




Thank you very much Steve Lord. I think that's the problem. I wrote everything in the same file called trial.m. It worked when I created two separate files. I trial.m I wrote only the first two sentences and in another file I wrote the rest four sentences and it worked.
Thank you very much.
Prabodh.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.