Ali Hashmi
• Member for 6 years, 10 months
• Last seen this week

the problem was in the comparator operator i.e. the IF statement. I have used the difference and Chop as the fix: If[Chop[ptTri[[1]] - source, 10^-8] == {0., 0., 0.}...] rather than If[ptTri[[1]] == ...

here is a little fix that should work for both cases: datamodified = data /. {0.4500000000, 9.803074361, -0.2935999100} -> {0.4500000000, 9.803074361, -0.3935999100} (* this will make vertices of ...

I think the problem might be in the way we preprocess the image. Here is a fix: (* finding the boundary *) i = Import@"http://i.stack.imgur.com/PcWcz.png"; img = MorphologicalPerimeter@Binarize@...

ff[v_List, n_Integer] := Last@Reap[Do[Sow[ConstantArray[i, n]], {i, v}]]~Flatten~2; ff[{3, {1, 4}, 1}, 3] (* {3, 3, 3, {1, 4}, {1, 4}, {1, 4}, 1, 1, 1} *) another way: foo[{}, _] := {}; foo[list_, ...

Based on solutions proposed by @Leonid and @WReach I have noticed something peculiar with the use of Block and With for the Trott-Strzebonski solution. Consider the following code: f[x_] := x^2; g[...

Adapted from C.E. here is a way to do it with recursive backtracking. We backtrack in this solution because I use a variable which is accessible to all the local scoping constructs and is deliberately ...

We can conveniently do it using SequenceHold as the function attribute and passing the values with a head Sequence to the Function Function[{x}, p@x, SequenceHold][Sequence[1, 2, 3]] (* p[1, 2, 3] *) ...

points = {{0, 1, 2}, {2, 4, 2}, {2, 1, 2}, {2, 3, 4}}; check[list_] := DeleteDuplicates[Delete[list, 2]] == {2}; Position[points,Except[List, _?check], {1}] (* {{2}, {3}} *)

Map[Total, b, {2}] (* {{2, -2, 0}, {-2, 2, 0}, {-1, -1, 2}} *) c = Extract[a, Position[Map[Total, b, {2}], 2]] (* {{0., 0.5, 0.4}, {0.5, 0., 0.4}, {0.6, 0.6, 0.}} *) DeleteCases[c, 0., {2}] (* {{0.5,...

so far i have found that Compile does a pretty neat job in speeding up the computation func = Compile[{{list1, _Integer, 1}, {list2, _Integer, 1}}, Outer[Abs[#1 - #2]/Max[#1, #2] &, list1, list2]...

rr = {{t, -1}, {1, t}, {t, 1}, {-1, t}}; rotations = Map[RotationTransform[#][rr] &, Range[0, 2 Pi, 2 Pi/5]]; ParametricPlot[rotations, {t, -1, 1}]

alternatively we can use GroupBy list = {{x -> 1, y -> 2}, {x -> 2, a -> 5}}; Normal@GroupBy[Flatten@list, Keys -> Values, Total]; (* {x -> 3, y -> 2, a -> 5} *)

expr /. {(p : Derivative[PatternSequence[1, 0, 0]])[u] :> Operate[RotateRight, p[u]], (q : Derivative[PatternSequence[0, 1, 0]])[u] :> Operate[RotateLeft, q[u]]}

This approach uses SequenceCases SequenceCases[list, {{_?(# <= 3 &)} ..} | {{_?(# > 3 &)} ..}] (* {{{1}, {2}, {3}}, {{4}, {5}}} *)

{comps, boxes} = Module[{seg, img = img, cm, newComps, bounds}, seg = MorphologicalComponents[img]; cm = ComponentMeasurements[{seg, ColorNegate@img}, {"MaskedImage","BoundingBox"}]; bounds = cm[[All, ...

ReadList["C:\\Users\\Ali Hashmi\\Desktop\\file.dat", String, NullRecords -> True] // SequenceCases[#, {Except[""] ..}] & // ToExpression@*StringSplit /@ # & (* {{{1, 2}, {3, 4}, {5, 6}}, ...

Function to solve a wall with unknown parameters solveWall[list_List] := With[{sym = Cases[list, _Symbol, {2}]}, FindInstance[#, sym, Integers] &@(And @@ Map[x \[Function] First@x == Last@x, #...

using TagSetDelayed as pointed by @J.M. and @Leonid FractionSum /: Normal[FractionSum[{patt : RuleDelayed[_, _Symbol] ..}]] := With[{sym = {patt}[[All, 2]]}, Plus @@ (Power[#, -1] &@Table[First@...

data = {{"No", "Vol", "Vel"}, {1, 500, 45}, {2, 700, 67}, {3, 350, 87}, {4, 123, 23}, {5, 587, 45}, {6, 435, 89}, {7, 896, 65}, {8, 125, 45}, {9, 476, 27}, {10, 987, 80}} dataset = Dataset[...

ClearAll[f]; f[x_List] := Table[Hold[{#}] &@(x[[i]] + x[[i + 1]]), {i, 1, Length[x] - 1}] Defer@@(f[{x, y}] + f[{x, 0}] + f[{y, 0}]) /. Hold[arg_] :> arg (* {x} + {y} + {x + y} *)

Module[{module, lines, points, area, region, pointsinout, linesinout, memberpoints, lineswithin, indexshared, func, posTrue, thread, linesoutside}, module = {{0, 0}, {0, 43}, {11, 43}, {11, 45}, {15,...

you can change the value of y_min and y_max to change the range on y axis (see below). Btw, instead of posting an open ended or a vague question, try to post your code to demonstrate your effort Plot[...

there is another way as well: #1 & @@ {1, 2} (* gives 1 *) #2 & @@ {1, 2} (* gives 2 *) for multiple coordinates in a list: data = RandomInteger[{1, 100}, {10, 2}] #1 & @@@ data (* ...

not a general answer (it is specific to the maze above or when the pixel distance is very small). Assuming distance to be Euclidean, the code below finds distance between neighbours (ignores any pair ...

With[{n = Range @ 256}, Reverse @ Table[UnitStep[n - i], {i, 256}]]; // RepeatedTiming (* {0.000244, Null} *) Relatively small example:

Full Code on github: https://github.com/alihashmiii/simple-piv/blob/master/flowtrack.m PIV[image1_?ImageQ,image2_?ImageQ,win_Integer,pivmethod_]:=Module[{windowsize=win, imgDim=ImageDimensions[image1]...

expr = {(256 m2)/(ϵ M (-1 + b x) (1 + b x)), (256 ϵ m1)/(M^3 (-1 + b x) (1 + b x))}; Replace[#,Times[PatternSequence[___, Verbatim[ϵ]]] -> 0, {1}] & /@ expr (* {(256 m2)/(M (-1 + b x) (1 + ...

You have answered your own question where you posted the question. Alternatively, Cases[list2, x_ /; Plus @@ x < 0.5]