Tag Info

New answers tagged

1

s = FileNames["C:\\*.csv"]; selectfromAll = Select[s, StringMatchQ[#, ___ ~~ "rob" ~~ ___] &] Pane[Column[{CheckboxBar[Dynamic[selected], selectfromAll, Appearance -> "Vertical"], Dynamic[selected], Button["Import", imported = Import /@ selected]}]]


0

Try Button["Press to find max", Print@Max[{list1, list2}]] for your button.


8

You probably want a workflow similar to this. First locate one or more Excel files: files = SystemDialogInput["FileOpen", {NotebookDirectory[], {"Excel File" ->{"*.xlsx","*.xls"}}}, WindowTitle -> "Import Excel File"]; Then import the selected files and do something with the imported data (what that something is, we don't know so no point in ...


7

While I wait for a more complete description of your needs please see: How to | Insert a File Path FileNameSetter SystemDialogInput And try: FrontEndTokenExecute["FileNameDialog"] Or: SystemDialogInput["FileOpen"]


0

DynamicModule[{x = 5,n}, Dynamic[ n = Table[Symbol["p" <> ToString@i], {i, 1, x}]; {InputField[Dynamic@x], Dynamic@n} ]] or alternatively DynamicModule[{x = 1, n = {p1}}, {InputField[Dynamic[x, (x = #; n = Table[Symbol["p" <> ToString@i], {i, 1, #}]) &]], Dynamic@n} ]


2

I am not sure if this answer you, since not clear why you are doing this. btw calling the table as n is not good naming, changed to tab) DynamicModule[{x = 5, tab}, Dynamic[Row[{ tab = Table[Symbol["p" <> ToString@i], {i, 1, x}]; InputField[Dynamic@x], Dynamic@tab} ]] ]


4

Using RegionNearest Imagine the triangle as a one-dimensional region, r1, a line, embedded in a plane. r1 = Line[{{0, 0}, {3, 1}, {2, 0}, {0, 0}}]; RegionDimension[r1] RegionEmbeddingDimension[r1] 1 2 Get the radius of a circle, with the triangle centroid as center, that intersects the farthest vertex of the triangle. c = RegionCentroid[r1]; (* ...


2

Everywhere wrapping pt in Dynamic allows it to be updated without triggering changes in the CountourPlot, which is independent of pt: Manipulate[Module[{}, p1 = ContourPlot[expr /. {x -> x, y -> y}, {x, -5, 5}, {y, -5, 5}, Contours -> 20]; grad = D[expr, {{x, y}}]; ngrad = grad /. {x -> Dynamic[pt[[1]]], y -> Dynamic[pt[[2]]]}; p2 = ...


13

If you interpret your geometric shape as NURBS of degree 1 (linear), you can proceed with the following, extremely simple code: pts={{0, 0},{1, 1},{0.5, 1.5}}; (* just an example *) s=BSplineFunction[pts,SplineClosed->True,SplineDegree->1]; Animate[ParametricPlot[s[t],{t,0,1},Epilog:>{Red,PointSize[Large],Point[s[t]]}],{t, 0., 1.}] This yields ...


6

e = {{0, 0}, {1, 1}, {5.5, 1.5}, {0, 0}}; (*triangle vertices*) (*point position as a function of time*) p[t_, e_] := Piecewise[{ {(1 - t)*e[[1]] + t*e[[2]], 0 <= t <= 1}, {(1 - (t - 1))*e[[2]] + (t - 1)*e[[3]], 1 < t <= 2}, {(1 - (t - 2))*e[[3]] + (t - 2)*e[[1]], 2 < t <= 3} }]; (*animation*) Animate[ Show[ ...


6

Thanks to kguler, I now know there is something like: LineScaledCoordinate. vertices = Table[{Cos[i], Sin[i]}, {i, 0, 2 Pi, 2 Pi/3.}]; Needs["GraphUtilities`"] Slider[Dynamic@t] Graphics[{ EdgeForm @ Thick, FaceForm @ None, Polygon @ vertices , AbsolutePointSize @ 12, Red, Dynamic[Point[LineScaledCoordinate[vertices, t]]] } ] Just in ...


7

If you want full flexibility you should try EventHandler and graphics primitives. If you can decipher the following example you will get the idea: color = Black; positions = Position[DiskMatrix[5], 1]; disks = {color, Disk[#, 0.4]} & /@ positions; eventHandler[item : {c_, obj_: Disk[p_, _]}] := {c, EventHandler[obj, "MouseClicked" :> (disks = ...


5

Step 1 As a very quick example of how one might start, with the limitation of only one "type" available: convert[Grid[m_?MatrixQ, ___]] := m[[All, All, 1]] Defer[convert]@Grid[ConstantArray[RadioButton[], {4, 7}], Spacings -> {0.2, 0}] Which outputs: You then make a selection: And evaluate it (the output), yielding: {{False, False, False, ...


0

Manipulate[ splot = StreamPlot[{z*(\[Beta] - \[Alpha]* Cos[2*\[Phi]]), \[Alpha]*(1 - z^2)*Sin[2*\[Phi]]}, {\[Phi], 0, 2 Pi}, {z, -1, 1}, StreamStyle -> GrayLevel[0.2], PlotRange -> {{0, 2 Pi}, {-1, 1}}, StreamPoints -> Fine, StreamScale -> Tiny, ImageSize -> 1000, FrameTicks -> {{{-1, -0.5, 0.0, 0.5, 1.0}, ...


2

Here's another workaround: Use Show to wrap the Image3D with Graphics3D. This changes how the graphics are processed by the Front End (I suspect). Evidently the FE is grabbing the graphics parameters such as the view point, and dealing with it. I don't know enough to give a complete explanation. Certain things are optimized, such as using the GPU ...


10

I have not fully diagnosed the problem, but it appears as if vv and vp are not initialized when you effectively wrap a Dyanmic module within a dynamic module (which is what you've done with the Manipulate. Changing your DynamicModule into the Manipulate seems to get the result you desire if you Initialize vv and vp: Clear[vv, vp] Manipulate[ With[{img1 = ...


3

You can set up list of opacities automatically data = {{1, 2, 3}, {2, 5}, {0, 6}}; Manipulate[ListPlot[data, Joined -> True, PlotRange -> {-1, 5}, PlotStyle -> (Opacity@Boole@MemberQ[x, #] & /@ Range@Length@data)], {{x, {1}}, Dynamic@Range@Length@data, ControlType -> TogglerBar}]


3

data = {{1, 2, 3}, {2, 5}, {0, 6}}; Manipulate[ ListPlot[data[[x]], Joined -> True, PlotRange -> {-1, 5}], {{x, {1}}, Range@Length@data, ControlType -> TogglerBar} ] With more togglers toggled: With differently size data data = {{1, 2, 3}, {2, 5}}; Manipulate[ ListPlot[data[[x]], Joined -> True, PlotRange -> {-1, 5}], {{x, {1}}, ...


5

It is unclear whether the checklist reflects the total number of boxes checked or the position of the boxes. For example if you only has the second box checked do you want to see [1/2] or [2/2]? Having said that here is something quick to try: x = {False, False}; CellPrint@ TextCell["Tasks", "Subsection", ShowStringCharacters -> False] CellPrint@ ...


0

So I found a way: Using InputFields for both in- and output arbitrarily. Ranking the InputFields to automatically choose the field for output, although this could be achieved in many other ways, e.g. checkboxes etc. Achieving immediate responsiveness in all Inputfields upon editing using ContinuousAction. Help-function, ranking and choosing ...


7

Like Mike said in a comment, the key is to use the second argument of Dynamic. In this case I've built a function updateCurrencies which modifies a global variable currencies which holds an Association object with all the currency values in it. currencies = <| "USDollars" -> 0, "Euros" -> 0, "BritishPounds" -> 0, "SwedishKronor" ...


1

Something like this could be shorter: loc[col_] := Graphics[{Darker[col, 0.5], Table[Circle[{0, 0}, i/2], {i, 3}], Table[Rotate[Line[{{0.1, 0.25}, {0.1, 1.75}}], t, {0, 0}], {t, 0 , 2 Pi, Pi/2}]}, ImageSize -> 20]; mod = a*(# + e)^2 + d &; data = Import["http://i.stack.imgur.com/SmQLj.png", ImageSize -> ...


1

Okay, I know it's strange to answer my own question, but I hope other people with similar problems will appreciate this: I found a way to have the same functionality that runs much much quicker, using Manipulate (which I wanted to avoid in the first attemot, because I thought DynamicModule would get faster results :) ) So here is the code that works fine for ...


1

I'm still not sure about details of behaviour you are after but you can certainly build on this: Basicaly you can use the second argument of Dynamic. ClearAll[a, b, c]; a = b = c = 1; Grid[{ {"a", "b", "c"}, { InputField[ Dynamic[a, (a = #; If[# =!= Null, c = a b/2]) &]], InputField[ Dynamic[b, (b = #; If[# =!= Null, c = a b/2]) &]], ...



Top 50 recent answers are included