Hot answers tagged

5

Well, basically your code is designed with a less efficient algorithm. Bear in mind that Mathematica generally treats a matrix the "same" as a number, so don't spend time on computation conducted at the number level. Then we can convert your code to be running at the matrix level, where the speed is much increased. len = 20; data = RandomReal[{1, 10}, ...


5

JasonB beat me to it, but for completeness, there's plenty on circle fittings in this post. I thought you wanted to show the second data set had a larger radius, but now I believe what you really want is the average circle of the two data sets. Regardless, here's another function for finding the center and radius of a circle from a list of coordinates: ...


3

If you are assuming that the data is circular, then you can fit the data to a circle and use the radius and center of that circle. Using a modified form of ubpqdn's function posted here, you can find the center and radius, circfit[pts_] := Module[{reg, lm, bf, exp, center, rad}, reg = {2 #1, 2 #2, #2^2 + #1^2} & @@@ pts; lm = LinearModelFit[reg, ...


3

You can use Cases to extract the Line objects from the contour plot, and then extract the points from those lines. ListContourPlot[Table[{i, Sin[i] // N}, {i, 0, 10}], Contours -> {2 - 0.1, 2 + 0.1}, ContourStyle -> Black, ContourShading -> {White, Black}] Cases[Normal@%, Line[pts__] -> pts, Infinity] (* {{{1., 3.1}, {1.31481, 4.}, ...


3

As mentioned in the comments to your question, you just Import the whole data and then manipulate it afterwards. This is (I believe) a very transparent way to achieve the end result that you want and also illustrates why you should not use an "advanced" Import: Let's produce some sample data dim = 100; data = RandomReal[{-1, 1}, {dim, 3}]; ...


1

You need to evaluate the cells. You can evaluate the current cell by using "Shift+Enter". For an introduction to evaluation, here are some helpful references: Interactive Usage page of The Wolfram Language: Fast Introduction for Programmers. Practicalities of using the Wolfram Language from An Elementary Introduction to the Wolfram Language by Stephen ...


1

What follows is a variation on a previous answer To exclude row 4 from comma-delimited data: dataGood = Flatten[#, 1] & @(Import["/path/to/myfile.txt",{"Data", #, {All}}] & /@ {Range[3], Range[5, 6]}); and dataGood // TableForm For comparison: dataAll = Import["/path/to/myfile.txt", {"Data", {All}, {All}}]; dataAll // TableForm ...



Only top voted, non community-wiki answers of a minimum length are eligible