Tag Info

Hot answers tagged

5

Best to try and work with the entire lists rather than loop through it with For or Table. You obviously have your reasons for your algorithm but to me it is strange because if your test returns True then you effectively increment twice. Which you can see with this version of your code: list = {}; new = data[[All, 1]] For[i = 1, i < Length[data[[All, ...


5

I am not sure what the exact aim is and time does not permit refining some loose ends. Assuming reason to believe data is ellipsoid (as test data is): Using test data from another answer: data = Flatten[ Table[{RandomReal[{1.9, 2.1}] Cos[n/100 2 Pi] Sin[m/100 Pi], RandomReal[{0.9, 1.1}] Sin[n/100 2 Pi] Sin[m/100 Pi], RandomReal[{0.9, 1.1}] ...


5

This is not very Mathematica style, but it will do the job. We start with a trial data set which is confined in an ellipsoid data = Flatten[ Table[ {RandomReal[{1.9, 2.1}] Cos[n/100 2 Pi] Sin[m/100 Pi], RandomReal[{0.9, 1.1}] Sin[n/100 2 Pi] Sin[m/100 Pi], RandomReal[{0.9, 1.1}] Cos[m/100 Pi]}, {m, 100}, {n, 100}], 1]; ...


4

sol = NSolve[2 x^3 + x^2 - 5 x + 2 == 0, x] (* {{x -> -2.}, {x -> 0.5}, {x -> 1.}} *) Judging from OP's acceptance of this answer, the task is turn sol into {{a -> -2.}, {b -> 0.5}, {c -> 1.}} Here are a few methods, sorted by StringCount, to relabel x new = {a, b, c}; List /@ Thread[new -> (x /. sol)] List /@ Thread[new -> ...


3

For demonstration purpose I'll use some simple test data test = Range[20]; test[[5]] = 200; test[[7]] = -200; test {1, 2, 3, 4, 200, 6, -200, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} Here is a way using one of the Sequence* functions introduced in version 10.1 of Mathematica: (test[[# + 1]] = Mean@test[[{#, # + 2}]]) & /@ ...


3

There are some problems with your example code, you are incrementing i twice, it looks like you might subscript past the end of data, etc. Consider this idea. It sounds like you are looking at triples in your data. So start with Partition[data, 3, 1] That is going to take overlapping triples of your data and you process each triple separately. Now write ...


3

Dilation produces the same output as MaxFilter and has comparable speed. test = {5, 6, 9, 3, 2, 6, 7, 8, 1, 1, 4, 7}; Dilation[test, 1] (* {6, 9, 9, 9, 6, 7, 8, 8, 8, 4, 7, 7} *) It also has a Padding option which may be convenient: Dilation[test, 1, Padding -> 10] (* {10, 9, 9, 9, 6, 7, 8, 8, 8, 4, 7, 10} *) Dilation[test, 1, Padding -> ...


1

Here's sample data: testdata = {{2, 0, 0}, {-2, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 5}, {0, 0, -5}, {1, 1, 4}, {2, 4, -3}}; Here's the covariance matrix: myCov = Covariance[testdata]; Here's the solution (z value) for a best-fit ellipse: mysols = Solve[{x, y, z}.Transpose[myCov].myCov.{x, y, z} == 5, z] {{z -> (17119 x + 51177 y - 8 ...


1

I begin with a bit of general advice: You want to find a function $t(n)$ for which you know that $t(n_1)=t_1$, $t(n_2)=t_2$ (where $n_i$ and $t_i$ are your measured data). The problem is that there are infinitely many such functions. In order to choose from them the ones that "make sense" you need to apply your judgement. Generally speaking, asking ...



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