MATLAB: Matlab doesn’t fit :(

fitwoods saxon

I'm trying to generate a fittype to fit my data, but matlab only plot a y=0 function. I don't know what to do, i've tried all. This is my code
x=[369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449];
y=[26 26,7500000000000 31,5000000000000 28,2500000000000 28,7500000000000 39,5000000000000 30 32 25,2500000000000 36,2500000000000 22,5000000000000 28 39,2500000000000 41,2500000000000 38,7500000000000 30,7500000000000 24,5000000000000 32,7500000000000 23,5000000000000 25,5000000000000 24,7500000000000 30 31 23,2500000000000 25 30,2500000000000 19,2500000000000 24 23,7500000000000 24,2500000000000 22,2500000000000 25,7500000000000 13,2500000000000 11 23 10 14,5000000000000 21 17 15,2500000000000 19,7500000000000 17 18 14,7500000000000 12 11,2500000000000 14 5,75000000000000 7 13 8,25000000000000 6,75000000000000 11,5000000000000 9,25000000000000 3,50000000000000 11,5000000000000 3,50000000000000 8,25000000000000 6,50000000000000 -1 5 10,2500000000000 11,7500000000000 11,2500000000000 8 4 5 2,75000000000000 4,75000000000000 4,75000000000000 12,2500000000000 11 3,25000000000000 3,75000000000000 4,50000000000000 4,50000000000000 5,50000000000000 7,25000000000000 16 7,75000000000000 8,25000000000000];
myfittype=fittype('v/(1+exp((x-r)/a))','independent',{'x'},'dependent',{'y'},'coefficients',{'v','r','a'});
myfit=fit(x',y',myfittype,'DiffMinChange',0.0000001)
plot(myfit,'--r',x,y,'.k');
The function is a woods-saxon typus
I would be very happy if somebody can help me, I don't know what to do!:(

Best Answer

The random start point used is a terribly poor choice here. That is a common problem with ANY exponential variation of fit, as a random start point makes no sense, often resulting in overflows or underflows.
Supply an intelligent set of starting values. For example:
myfit=fit(x',y',myfittype,'DiffMinChange',0.0000001,'start',[25 360 20])
Related Question