Mark R
  • Member for 2 years, 6 months
  • Last seen this week
2 answers
4 votes
172 views
Sampling and filtering data
Accepted answer
5 votes

Three important points: Fourier is symmetrical with half of the data repeated (you see this in your plot) There is a DC term. You want to filter the original signal, not the Fourier. And make sure ...

View answer
3 answers
6 votes
141 views
Automatic data evaluation and elimination
5 votes

As others have said, the original data is too far off a linear fit to have any points survive your constraint. I think this function will do what you want: TrimDataWithLinearFit[{data_, ...

View answer
2 answers
9 votes
526 views
Removing horizontal noise artefacts from a (SEM) image
5 votes

I like what @halirutan did and had a slight riff on it that appears to yield a better result. Rescale[With[{meanFiltered = MeanFilter[#, 50]}, # - meanFiltered] & /@ ImageData[img, "Real"]] // ...

View answer
32 answers
27 votes
3k views
Benchmarking with Mathematica v.12 for up to date comparison across different machines
4 votes

My machine specs seem identical to @rohit-namjoshi yet my result is different: {{"System", "Mac OS X x86 (64-bit)"}, {"BenchmarkName", "WolframMark"}, {"...

View answer
2 answers
2 votes
263 views
Using Multiple Initial Conditions
Accepted answer
4 votes

I think this will do what you want: s = NDSolve[{r''[t] == r[t]*\[Phi]'[t]^2 - 1/r[t], \[Phi]'[t] == #[[4]]/r[t]^2, \[Phi][ 0] == #[[1]], r[0] == #[[2]], r'[0] == #[[3]]}, {r, \[...

View answer
2 answers
0 votes
40 views
How can Mathematica quickly evaluate a scalar $g(x,y)$ given a long list of points $(x,y)$?
3 votes

The solution shown is fine but if you want to extend it to n-dimensions, try this: g[a_List] := Total[#^2] & /@ a Now, if you give this: nDim = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; g[nDim] (*{14,...

View answer
2 answers
9 votes
243 views
Generating long binary lists fast?
3 votes

I think this might work for you: Elaborate[aList_List] := Block[ {result, splitList, currentPosition}, result = {1}; currentPosition = 0; splitList = Split[Reverse@aList]; (If[First[#]...

View answer
2 answers
6 votes
280 views
How to write a string verbatim
3 votes

I think this would do what you want: writefile[instr1_, instr2_, filename_] := Module[{str1, outstr, stream}, str1 = "abc\n" <> instr1 <> "\n" <> "def\n" <> instr2 <&...

View answer
3 answers
1 votes
101 views
Fittings of three equations
3 votes

I like the solution from @morbo but think that Subsets is better in this case than Permutations. Permutations will give {1,3} and {3,1} (thinking of this as a set of three values and just looking at ...

View answer
7 answers
5 votes
910 views
Generating list with short code
3 votes

Or this (inspired by the FindSequenceFunction reported by @march): ClearAll[aList, sf,testList]; aList = {1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}; sf = FindSequenceFunction[aList]; ...

View answer
2 answers
3 votes
194 views
How to draw scatter diagram according to {month, day} time format
3 votes

Or another variant: DateListPlot[ReplacePart[#, 1 -> Prepend[#[[1]], 2020]] & /@ data]

View answer
4 answers
2 votes
924 views
one list minus another
3 votes

I didn't at first understand the problem statement. We are subtracting the second list from the second element of the first list. With that understanding, here is another possibility: Transpose[{...

View answer
2 answers
2 votes
51 views
How to derive an association from a SemanticImport of a website's data?
3 votes

This might give you what you want. ClearAll[ratioFile,knownRatios] ratioFile=SemanticImport["http://www.huygens-fokker.org/docs/intervals.html"]; knownRatios=Association[Flatten[StringCases[#, a:...

View answer
5 answers
4 votes
212 views
Generate random non-zero "island" in matrix of zeros
3 votes

I don't know if this is what you had in mind, but playing around with what you are doing, I came up with a couple of new routines. ClipAll[nElements_List, min_, max_] := Thread[Clip[nElements, {...

View answer
1 answers
2 votes
56 views
Eliminate date in a list
Accepted answer
3 votes

I frequently use this shorthand (use "-1" for last or could also use "2"): Btc[[;;,-1]]

View answer
2 answers
3 votes
117 views
Finding the coefficients of an expression
2 votes

I think I may have figured this out. Looking up TreeForm, I found FullForm. anExpression = 5.101102275075902` + E^(-6876.316769642943` t) (-5.101102275075902` + 1.` vStart); depth = Depth[...

View answer
4 answers
2 votes
302 views
How can we make the input of a function multiple lists?
2 votes

If you want the braces for the output as you say, then you could do something like this with a pure function: someInput = RandomInteger[{1, 10}, {10, 4}] {Total[#]} & /@ someInput (* {{5, 9, 9, 9}...

View answer
1 answers
2 votes
98 views
How can I get rid of curly brackets writing minimization output to file
Accepted answer
2 votes

Something like this might work for you: fnew[D1_, D2_, x_] := -2 Sqrt[2] D1 Cos[x/2] - D2 Sin[x]; fnewSolution[D1_, i_] := Block[{D2 = D2start + i*D2step, minsol, theX}, minsol = NMinimize[fnew[D1, ...

View answer
3 answers
4 votes
117 views
Display Table output as a grid of points
Accepted answer
2 votes

Inspired by @kglr and extending to arbitrary dimensions on the data, this may do what you want: data = Module[{size = 11}, Table[If[PrimeQ[a + b], True], {a, 1, size}, {b, 1, size}]]; With[{...

View answer
1 answers
0 votes
115 views
Plot 2-D system difference equations
2 votes

I don't think this is quite correct. To test my hypothesis, I created this: NextXY[{x_, y_}] := {x - 5 y, 2 x + y} Then, I created some points: somePoints = {#, NextXY[#]} & /@ Flatten[...

View answer
2 answers
2 votes
144 views
Plotting function takes forever
2 votes

Perhaps not very satisfying, but I was able to get this to complete in a reasonable amount of time (1 minute, 16 seconds): plotValues = ParallelTable[{x, FS12[x]}, {x, 0.01, 2, .01}]; ListPlot[...

View answer
1 answers
1 votes
128 views
mutiply x axis by a factor
Accepted answer
2 votes

There are perhaps more elegant answers, but let's say you want to scale the x-axis by 10^17. Then this would do that: equation1[ F_] := (3.47471*10^31 (3.525 + 3.83003*10^-10 F^2))/(0.5814 + ...

View answer
3 answers
1 votes
81 views
Using select to replace values which meet a condition
2 votes

Would something like this do what you want: Block[{outlierPositions = Flatten[Position[SomeData, #] & /@ Select[SomeData, ! (#[[2]] - #[[3]] < 0.2) &], 1], replacements}, ...

View answer
3 answers
9 votes
581 views
How can I get all 4 × 4 submatrices of an n × n matrix?
2 votes

Might not be so elegant, but try this: (* create a test array *) startingArray = ArrayReshape[Range[36], {6, 6}]; startingArray // MatrixForm all4x4 = Partition[Partition[#, 4, 1] & /@ ...

View answer
1 answers
0 votes
33 views
Parsing time interval strings as "Uncertain" Time Intervals
Accepted answer
2 votes

This might work for you. timeRules = {"m" -> "Minutes", "hr" -> "Hour", "min" -> "Minutes", "h" -> "Hour"}; ParseTime[timeString_] := With[{numberString = First@StringCases[...

View answer
5 answers
6 votes
258 views
Maximizing efficiency of a power-tower (tetration) calculation
2 votes

I will update this with the plot (if it ever finishes!). Here is some code that I believe computes the value: thePoints = ParallelTable[ {x, y, NestWhile[ {#[[1]] + 1, Quiet@Chop[zStart^...

View answer
5 answers
2 votes
96 views
Build a new flat list from a mix of part items and part spans
2 votes

Another alternative: Join[#[[1 ;; 3]], {#[[1]] > 2 b, #[[4]]}] & /@ data

View answer
2 answers
5 votes
814 views
How can an envelope be drawn around a scatter plot?
2 votes

The following seems to have slightly less "wiggle" and doesn't need tuning: ClearAll[allXValues,minY,maxY,nearestMax,nearestMin] allXValues = Sort[pts[[;; , 1]]]; {minY, maxY} = MinMax[pts[[;; , -1]]]...

View answer
2 answers
1 votes
150 views
How to define a function to be used in a loop?
2 votes

Rewriting it like this fixes the error: index[start_Integer, u_Integer] := Abs[i1[[start, u]] - i0]; Then, your for loop becomes this For[u = 1, u <= 7, u++, x[[u]] = Position[index[300, u], ...

View answer
2 answers
0 votes
77 views
Constricting variables in NMinimize to binary (0,1) value
1 votes

I'm not sure if this is an "answer" to what you ask, but when I use testprogress = {}; testopt = NMinimize[{Hold[Testfunction[x1, x2, x3, x4]], 0 <= x1 <= 1 && 0 <= ...

View answer