Message Boards Message Boards

0
|
14877 Views
|
13 Replies
|
7 Total Likes
View groups...
Share
Share this post:

[?] Plot data from csv file?

Hi i have a problem i can't plot numbers which are contained in a table in this form, i have imported this data from a csv file:

{
 {"101  -0.377"},
 {"101.02   -0.407"},
 {"101.04   -0.419"},
 {"101.06   -0.434"}
}

i want to make a a graphic where in x there is the first column and in y the second, i've tried several ways and i didn't succeded on it. Thanks for answering. I put the file below.

Attachments:
POSTED BY: Riccardo Moro
13 Replies

Thanks a lot, really.

POSTED BY: Riccardo Moro

here is the file with more comments showing how to get the data.

The 6 is a starting value for the variable "b". if you leave out starting values they all start at 0. When you do that, the fit gets stuck at a local minimum which is not very good. If you start it at 5 or 6 you get the best fit.

Study the file and look at the documentation.

Attachments:
POSTED BY: Neil Singer

Ok no i didn't succeded sorry:( can you explain how to get data in order please

POSTED BY: Riccardo Moro

Ok i've understood the passages, thank a lot for the attention you are giving to me. If you can explain how to get data in order it would be wonderful. I add the file with numbers. Thanks again

Attachments:
POSTED BY: Riccardo Moro

I don't understand why did you put six in this line nlm = NonlinearModelFit[ndat, aSin[bx + c], {a, {b, 6}, c}, x]

POSTED BY: Riccardo Moro

ok i succeded on doing the fit thanks a lot!! can you only explain now why did you put the six inside nonlinearmodelfit? I can now do the relation Thank!!

POSTED BY: Riccardo Moro

you must have a typo (or data is undefined). Here is your file -- since I do not have your data file, I skipped that step. Your fit is numerically unstable because you will get stuck in local minima -- you can check the RSquared and adjust the starting value for b to get a different minimum. You get an answer if you start the frequency reasonably close to the "correct" answer.

I hope this helps

Attachments:
POSTED BY: Neil Singer

It gives me this error: Part::partd: Part specification data[[1]] is longer than depth of object.

POSTED BY: Riccardo Moro

your data is in the form of a list of a list of data points. you need to remove the outer list:

you have:

{{{1,1},{2,2}}}

you need to have:

{{1,1},{2,2}}

take the first element of data (which is the list you want):

NonlinearModelFit[data[[1]],....]
POSTED BY: Neil Singer

I have an another problems with NonLinearRegression Forgive my ignorance but i don't understand why the program doesn't fit my data, the number problem was fixed, but mathematica says that the list of numbers is not a list and it can't do the fit. I put below the program to see better what i mean.

Attachments:
POSTED BY: Riccardo Moro

Thanks a lot, you have saved me!!

POSTED BY: Riccardo Moro

Try this:

ToExpression /@ StringSplit[StringJoin[Characters[#] /. "\t" -> ","], ","] & /@ lalla;
ListPlot[%]
POSTED BY: Hans Dolhaine
Posted 7 years ago

Import the CSV file data values as numeric [In your notebook they have been imported as strings] :

Import["C:\\Users\\User\\Desktop\\Prova3.csv", "Numeric" -> True]

Or use SemanticImport command. Please check the documentation for more information.

Alternatively, you can still plot the values in your notebook:

ListPlot@ToExpression[Flatten[#, 1] & /@ (StringSplit /@ lalla)]
POSTED BY: Girish Arabale
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