Message Boards Message Boards

0
|
10841 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Help with data import into FindFit ? Or defining data import as a list?

Posted 11 years ago

Hi, I am trying to import data from an excel file and fit my model to it. I defined the data as a list:

data = Import["ExampleData/data.xls"] // List;

but I'm still getting the error:

FindFit::fitd: "First argument {{{{0.,69.},{0.1,439.},{0.2,1182.},{0.3,1616.},{0.4,1961.},<<41>>,{4.6,2294.},{4.7,2327.},{4.8,2393.},{4.9,2321.},<<1150>>}}} in FindFit is not a list or a rectangular array"

Those are the first bits of my data. I don't know what it could be looking for? I'm attaching my file and data in case it helps. I also tried defining it as a Table and I got the same error, but according to the "constructing lists" page they seem to be somewhat equivalent (both lists??) ...

Secondary issue, I had to delete every other column and page from my excel file to get it to stop importing the other columns. I was using

s = Import["ExampleData/data.xls"] // List;    
data = s[[3],All,{1,3}]

To get page 3, all rows, columns 1 and 3. It showed up like I wanted if i just called "data", but when I tried to call data within my functions it was throwing up errors referring to other columns I was trying not to include. Any help would be super awesome!

Attachments:
POSTED BY: Renee Dale
4 Replies
Posted 11 years ago

Ok yay got rid of that error thank you!! Yea my data is only for w, please tell me there's some simple solution to that? .... Here's what I tried:

 fit = FindFit[data[[1, 1]], 
   model[a, b, q, v, z, y, d][
    w], {{a, 54, 7, 150}, {b, 220}, {q, .16, .01, 
     1.5}, {v, .05, .04, .06}, {z, 
     6000000}, {y, .05, .04, .06}, {d, .0003}}, w, PrecisionGoal -> 4,
    AccuracyGoal -> 4];

(I also added ranges for the parameters). Now I'm getting:

"The function value xx is not a real number at xx"

Does it just not like my initial guesses?

POSTED BY: Renee Dale

Once you get the data is the right shape, the next thing you will run into is this message: FindFit::fitc: Number of coordinates (1) is not equal to the number of variables (4). >>

FindFit over independent variables labeled {s, w, r, c} will be expecting data of the form {{s1, w1, r1, c1, val1}, {s2, w2, r2, c2, val2}, .. }

Posted 11 years ago

So then why am I getting that error for FindFit? Is it because of something else I'm doing wrong and not actually the list stuff?

POSTED BY: Renee Dale

When you Import this file, it will come through as a List expression. There is no need to wrap it in another List. In fact the XLS file, having multiple pages, will already have an extra List layer. ListPlot will work, if you strip these both.

ListPlot[data[[1, 1]], PlotRange -> All]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract