﻿ Wolfram Mathematica_It technology blog_ Programming technology Q & A「QuestionBank」
QuestionBank

### Wolfram mathematica Wolfram Workbench and Mathematica Help System

I find the Wolfram Workbench a nice environment for Mathematica development. However, as I program in Mathematica, I need to navigate the Help System very often. The Workbench provides a tooltip tool that shows a very basic help for the Mma functions (just the usage messages), and is not enough for my usual needs. So: Is there a way to bring up and navigate the whole Mma Help System from inside the Workbench? Alternative solutions are also welcome. Re-entering the function name in a notebo

### Wolfram mathematica Custom Intervals of Markers in Mathematica PlotMarkers

I am trying to plot multiple lists in the same plot in Mathematica (ListLinePlot) and use PlotMarkers and the PlotLegend Package to get the final figure. The issue is that Mathematica puts a marker for every point and this makes it hard to tell which marker is where in the plot. Is it possible to have a plot marker appear every n sample (e.g. every 10 points for a 100 point plot). The Directive at the moment is PlotMarkers->{Automatic, Small}.

### Wolfram mathematica Mathematica, leftover zeros

I'm struggling how to get rid of expressions that are trivially zero in Mathematica from the output. Example: pVec = Table[{i, Exp[-i*0.03]}, {i, 0, 2.5, 1/2}]; pVec[[2, 2]] = p1; pVec[[3, 2]] = p2; pVec[[4, 2]] = p3; pVec[[5, 2]] = p4; pVec[[6, 2]] = p5; qq = Interpolation[pVec, InterpolationOrder -> 1]; >> qq[0.5] >> 0. (1 - p1) + p1 the 0*(1-p1) is obviously zero, but I couldnt find a way to get rid of it ? (I'm relatively new to Math

### Wolfram mathematica Creating points while using Mathematica's Table Function

I'm trying to plot points that I've created in a table in mathematica but for some reason one component of my points seems to have double braces around it while the other only has one as below: {{x},y},{{x1},y1}....{{xn},yn} and list plot will not recognize these as points and will not plot them. Here is my mathematica code: Remove["Global*"] b = .1; w = 1; Period = 1; tstep = 2 Pi/Period; s = NDSolve[{x''[t] + b x'[t] - x[t] + x[t]^3 - .5 Cos[w t] == 0, x' == 0, x == 0}, x[t], {t,

### Wolfram mathematica define a Linear Time-Delay system in Mathematica and plot it's Bode and Nyquist diagrams

I have a characteristic equation of a time-delay system and i can't define it with StateSpaceModel or TransferFunctionModel command in Mathematica; Because these commands only work for linear systems without delay. My purpose is to define a Time-Delay system in Mathematica 8.0.1 and plotting Bode Diagram and Nyquist Diagram for a system like this: g = ((s + 1) (1-E^(-2 s) + E^(-3 s)))/(s^2 + 2 s + 10)

### Wolfram mathematica repeat a function n times in Mathematica

I want to repeat a function n times on a table, For n=2 I have the following code, How can I be sure that the function had run twice since my fc is differend every time? smat = Table[{9, 8, 10}, {3}] f[x_?Table] := ReplacePart[ x, {{2, 1} -> x[][] - #, {2, 2} -> x[][] + #}] &@ fc[x[][]]; fc[k_?NumericQ] := Count[RandomReal[{0, 1}, k], x_ /; x < .1] Nest[f, smat, 2]

### Wolfram mathematica An efficient data structure or method to manage plotting data that grow with time

I'd like to ask if the following way I manage plotting result of simulation is efficient use of Mathematica and if there is a more 'functional' way to do it. (may be using Sow, Reap and such). The problem is basic one. Suppose you want to simulate a physical process, say a pendulum, and want to plot the time-series of the solution (i.e. time vs. angle) as it runs (or any other type of result). To be able to show the plot, one needs to keep the data points as it runs. The following is a simpl

### Wolfram mathematica How to define part of a Manipulate control variable definition to reduce code duplication

This is a little related to this question Define control as variable in Mathematica But the above question did not answer my problem, as it talks about the full control definition. (I also tried some of the tricks shown there, but they do not work for my problem). I am now asking about definition for only part of the control. (It is also very hard to follow up on an old question using this forum format. Because using the tiny comment area, it hard to ask and show more like when asking a new q

### Wolfram mathematica How can I test for bivariate normality using Shapiro-Wilk test in Mathematica?

I've computed the Pearson correlation coefficient between two lists and am now trying to verify whether these two data sets are normally distributed in order to ascertain the validity of the the correlation. From What I've read in the documentation, I should be able to use multivariate data with The ShapiroWilkTest function, but so far I have been unable to obtain an output. I do not receive an error, but the process hangs seemingly indefinitely. I am, however, able to obtain an output with uni

### Wolfram mathematica Problems passing options in specialized plot functions for Mathematica

This should be quick to an expert, but I'm relatively new at defining functions with options. Here is a schematic of what I've tried, I'll explain after showing the code: MyPlotFunction[params_, optionalparameter_List:{1,2,3}, opts:OptionsPattern[]]:= Plot [ stuff, {x,0,1}, Evaluate@FilterRules[{opts},Options@Plot]]; Options[MyPlotFunction] = { PlotRange->{-5,5}, Frame->True, ... other plot options}; There are four slight subtleties: I have an optional parameter in my functio

### Wolfram mathematica Nested Manipulate in Mathematica

Please consider: Function[subID, pointSO[subID] = RandomInteger[{1, 4}, {5, 2}]] /@ {"subA", "subB"}; Manipulate[ Manipulate[ Graphics[{ Black, Rectangle[{0, 0}, {5, 5}], White,Point@pointSO[subID][[i]] }, ImageSize -> {400, 300}], {i,Range[Length@pointSO[subID]]}], {subID, {"subA", "subB"}}] Provided that p

### Wolfram mathematica histogram without vertical lines in Mathematica

I am trying to make an histogram without vertical lines. I'd like to have a plot which looks like a function. Like this: The same question has been asked for R before ( histogram without vertical lines ) but I'm on Mathematica. I have been looking into the ChartStyle options without success.

### Wolfram mathematica Mathematica Splitted List with Length values

I have, in Wolfram Mathematica 8.0, a nested list like: {{1,1,1},{0,0},{1,1,1,1,1},{0},{1,1},{0}} and would like to substitute the ones with the substring lengths as follows: {{3,3,3},{0,0},{5,5,5,5,5},{0},{2,2},{0}} Can anybody show me a fast functional approach to this issue?

### Wolfram mathematica Mathematica output formatting

How does Mathematica decide when to round numbers in its output? For example, giving the input 250000.5 gives the output 2500001 While 25000.5 is indeed printed as 25000.5 N[] isn't helpful here either, I need to use NumberForm[] to get it to actually print 250000.5 as 250000.5 I'm a Mathematica newbie, and I'm sure its ridiculously easy to control this threshold for when it starts ignoring decimals in its output, but could somebody please point me in the right direction?

### Wolfram mathematica Function as parameter for Module

How is it possible to use a mathematical function as module- parameter Such as: PersonalPlot[fun0_, var0_, min0_, max0_] := Module[{fun = fun0, var = var0 , min = min0, max = max0}, (*this is incorrect*) fun = fun[var_]; Plot[fun, {var, min, max}] ] PersonalPlot[x^2,x,0,3];

### Wolfram mathematica Mathematica: Defining a function as the derivative or integral of a piecewise defined function

I am trying to evaluate a function that I have defined piecewise. I need to integrate it with respect to one variable and then take the derivative with respect to another (variables are independent). However, something in the way I am defining the functions is causing mathematica to throw errors or infinitely evaluate. I believe that the derivative function does not like the format of the output of the integrate function, and vice versa when I tired reversing the order of the steps. The integran

### Wolfram mathematica Mathematica custom notation / disable predefined function?

I cannot find how to use any variable name i want in mathematica. (I've searched where i could but i cannot think of the correct terms to search for) For example, I wanted to name one of my variables {pi}' (with {pi} I mean the greek pi, just cannot type it here). However, there are problems. First, {pi} is already predefined as a constant equal to 3.14.. Second, the prime (') symbol is predefined as derivative. So, {pi}' evaluates to 0& by default. Another example would be, if i want to n

### Wolfram mathematica result expanded to maximum (more) on wolfram alpha query

I am using mathematica to query wolfram alpha for a query. for that purpose I use: WolframAlpha["prime minister of france", "PodPlaintext"] I took the options from here: http://reference.wolfram.com/language/ref/WolframAlpha.html My problem is that I need info that is hidden at first and is located under the more option on the page. I was unable to find a way to query the full data (after more was clicked) from the mathematica. Any ideas how to achieve it?

### Wolfram mathematica Why are defined variables not turning black in Mathematica v10?

I just upgraded Mathematica from version 8 to 10, and I am having a problem with the syntax colouring. Before, when I assigned a value to a variable, it would turn from blue to black to indicate that it was defined. But now, even when I define variables, sometimes they stay blue! However, they still work as expected, meaning that there really is a value assigned to them, and I can call upon it. But why are they coloured incorrectly? It is very confusing to work with as I am not sure if a variabl

### Wolfram mathematica Using the Manipulate funvtion in Mathematica:

How is it possible to extend the scope of the slider variable beyong the 'Manipulate' function? In this coding 'n' = 10 before and after the 'Manipulate' function but can vary between -10 and +10 in the plot routine. n = 10; Manipulate[ Plot[Sin[n*x], {x, -5, 5}], {n, -10, 10, 1, Appearance -> "Labeled"}] Print["n = ", n] Thank you in advance for all contributors. Norman

### Wolfram mathematica Two quick Mathematica questions

How do I remove the numbers on the x-axis only not the y-axis? Is it possible to shift the y-axis without shifting the functions? What I mean is, instead of having the y-axis at x = 0, could I have it at x = -5?

### Wolfram mathematica Combinations with repetition

I'm using Mathematica 7 and with a combinatorica package function I can get all combinations of a certain number from a list of elements where the order doesn't matter and there is no repetition.e.g: in: KSubsets[{a, b, c, d}, 3] out: {{a, b, c}, {a, b, d}, {a, c, d}, {b, c, d}} I cannot find a function that will give me all combinations of a certain number from a list of elements where the order doesn't matter and there is repetition. i.e. the above example would include elements like {a,a,b

### Wolfram mathematica Rationalizing Numerical Output

Consider : Grid@Partition[ Text[Style[ToString[Range[0, 180, 22.5][[#]]] <> "\[Degree]", Bold, 16, GrayLevel[(8 - #)/10]]] & /@ Range, 2, 1] How can I get rid of the dot following the Integers ?

### Wolfram mathematica Is there a way to draw a set of lines in mathematica all with the same origin point?

I have a set of points given by this list: list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}}; I would like Mathematica to draw a line from the origin to all the points above. In other words draw vectors from the origin (0,0) to all the individual points in the above set. Is there a way to do this? So far I've tried the Filling option, PlotPoints and VectorPlot but they don't seem to be able to do what I want.

### Wolfram mathematica How to overlay two ReliefPlots, or other graphics

Is it possible to overlay two or more graphics in Mathematica, if the graphics are generated by functions such as ReliefPlot or DensityPlot, using Opacity to control the appearance? For example: a = ReliefPlot[ Table[i + Sin[i^2 + j^2], {i, -4, 4, .03}, {j, -4, 4, .03}], ImageSize -> 100] b = ReliefPlot[ Table[i + Sin[i^3 + j^3], {i, -4, 4, .03}, {j, -4, 4, .03}], ImageSize -> 100] Show[a,b] combines the two, but I can't work out how to insert an Opacity command anyw

### Wolfram mathematica Writing vectors to a file without using Export

I am interested in writing multiple vectors to a file such that each vector forms one row in the file, and is written to the file as soon as it is generated. The elements of the vector need to be separated by a single space, and I do not want to include the { } parentheses for the vector. Basically, I want to mimic the fprintf("file", "%f %f %f\n") functionality of C. Here is what I have. Is there a better way of doing this? st1 = OpenWrite["C:\\junk\\mu.out", FormatType -> OutputForm]; v

### Wolfram mathematica Mathematica 8.0, obvious simplification missed, why?

I apologize beforehand if there’s an obvious answer, I’m not a user of Mathematica but I’m working on a borrowed laptop and that’s what I have available for the moment. For some reason Simplify and FullSimplify are missing obvious simplifications, for instance: Simplify[1/2 (2/5 (x - y)^2 + 2/3 z)] Yields: 1/2 (2/5 (x - y)^2 + (2 z)/3) For some reason, it doesn't get rid of the 1/2 factor, try it yourself! Of course I can do it manually but I have much bigger expressions with the same pro

### Wolfram mathematica Cleanup data on one long line in Mathematica

I have a file of 12Mb approximately that has the following typology [["1",-154],["2",-100],["3",-28],["4",-66],["5",-222],["6",-309],["7",-196],["8",-50],["9",-53],["10",-209],["11",-355],["12",-350],["13",-269],["14",-264],["15",-392],["16",-513],["17",-515],["18",-434],["19",-418],["20",-505],["21",-592],["22",-559],["23",-422],["24",-384],["25",-539],["26",-716],["27",-713],["28",-593],["29",-534],["30",-647],["31",-813],["32",-857],["33",-711],["34",-582],["35",-594],["36",-700],["37",-721]

### Wolfram mathematica List of plotting options

I often use the same plotting arguments for Plot3D so I tried to make a list so I do not have to write them over and over. I tried: optlist = {Boxed->False, Axes->True, AxesOrigin->{0,0,0}}; Plot3D[eq, {x,-5,5},{y,-5,5}, optlist]; I am not a programmer and use Mathematica only for math-study.

### Wolfram mathematica Mathematica: Implementation of Partial Least Squares (PLS)?

I'm looking for a PLS implementation for Wolfram Mathematica. I just cant seem to find any implementation for it - do you know one? In general, I'm a bit confused that there exist only so few third-party packages/libraries for mathematica in general :( For now I probably will just use RLink in mathematica to be able to refer to the R package pls (http://cran.r-project.org/web/packages/pls/index.html) but a direct implementation in mathematica would be nicer for debugging and testing purposes...

### Wolfram mathematica Recommended hotpatch for Mathematica Link to NetLogo 6 didn't work

I have the same problem as the user who posted in "Unable to use Mathematica Link in NetLogo 6.0" (Unable to use Mathematica Link in NetLogo 6.0). For me, the Mathematica Link seems to work fine with Netlogo version 5.3.1. Even after I attempted the recommended hotpatch (which was the answer to the original posted question on this topic), still no luck (I get the same error message posted in the original comment cited above). I tried extracting the hotpatch in the NetLogo 6.0 directory and in th

### Wolfram mathematica Wolfram Mathematica show N until specific number is reached

Can anybody who's using Wolfram Mathematica tell me how i can show N until a specific number is generated? Want to show the value of pi until it reaches 6764.

### Wolfram mathematica Multiple assignment between lists in Mathematica 7

Suppose there are two lists a = {a1, a2, a3} and b = {b1, b2, b3}, and I want to write an assignment statement to make a1=b1,a2=b2,a3=b3 which only refers to a and b: Thread[a = b] But it only makes a={b1,b2,b3}. Using := (SetDelayed) instead of = doesn't work either. Any solution? Thanks.

### Wolfram mathematica How to make animations out of a Table of images in Mathematica 7

If I have a set of pictures, how can I make it so I can get an animation out of them? In old versions of Mathematica, it was possible to compact them and then double click them so it would show them as sequence(i.e., animation), but I'm now using version 7 of Mathematica and that doesn't seem possible. How can I do so? alt text http://img63.imageshack.us/img63/7972/d2ilrx0vvczls0ntmqsalgp.png

### Wolfram mathematica how to automatically load user-defined functions in mathematica

I have a bunch of user-defined functions that are frequently used in mathematica. I wonder if I can store them in separate files and mathematica will load them on start and treat them as built-in functions, so that I don't have to repeat the definitions whenever I create a new .nb file. Something similar to functions in Matlab... Thanks!

### Wolfram mathematica How to get rid of denominator in numerator and denominator in mathematica

I have the following expression (-1 + 1/p)^B/(-1 + (-1 + 1/p)^(A + B)) How can I multiply both the denominator and numberator by p^(A+B), i.e. to get rid of the denominators in both numerator and denominator? I tried varous Expand, Factor, Simplify etc. but none of them worked. Thanks!

### Wolfram mathematica nicely print out a matrix in mathematica

I have a list of lists (matrix) in mathematica. I want to print it out nicely, with the max in every row in bold. How to do this? Or maybe even further, with a circle outside such max, is this possible?

### Wolfram mathematica How to show plots inside a loop in mathematica

I am wondering if you have good ways to show plots inside a loop in mma. Usually, the output of Plot function is not shown, for example in the following code: For[i = 1, i <= 10, i++, Plot[Sin[i*x], {x, -Pi, Pi}]] Thanks for your help. Edit In connection to my previous question, I already have the For loop, for example, like this For[i = 1, i <= 10, i++, Plot[Sin[i*x], {x, -Pi, Pi}]]. Given this fact, I want to have something like "press any key to continue..." inside the For loop, the

### Wolfram mathematica Mathematica - DSolve spits out #1 in output

I'm not quite certain how to go about interpreting this. I'm solving a fairly large system of differential equations, DSolve sometimes spits out a list of replacement rules that include terms that have a #1 . I know that #1 is a placeholder for an argument, but I just have no clue where it comes from. If I have a system of equations similar to eqs = { x1'[t] = a1*x1[t] + b1*y1[t] x2'[t] = a2*x2[t] + b2*y2[t] ... y1'[t] = c1*y1[t] + d1*x1[t] y2'[t] = c2*y2[t] + d2*x2[t]} DSolve[eqs,vars,t]

### Wolfram mathematica Is Put - Get cycle in Mathematica always deterministic?

In Mathematica as in other systems of computer math the numbers are internally stored in binary form. However when exporting them with such functions as Put and PutAppend they are converted into approximate decimals. When you import them back with such functions as Get they are restored from this approximate decimal representation to binary form. The question is whether the recovered number is always identical to the original binary number and, if not always, in which cases it is not and how

### Wolfram mathematica Efficient And Conditional Tuples or Subsets

Stepping back from the following question : Selecting with Cases I need to generate a random Set (1 000 000 items would be enough) Subsets[Flatten[ParallelTable[{i, j}, {i, 1, 96}, {j, 1, 4}], 1], {4}] Further, I need to reject any quadruples with non-unique first elements, such as {{1,1},{1,2},{2,3},{6,1}}. But the above is impossible on a laptop. How could I just draw uniformly one millions sets avoiding killing my machine ?

### Wolfram mathematica Is this a bug of mathematica 8?

Why doesn't M@ know the result is zero?

### Wolfram mathematica smallest integer not obtainable from {2,3,4,5,6,7,8} (Mathematica)

I'm trying to solve the following problem using Mathematica: What is the smallest positive integer not obtainable from the set {2,3,4,5,6,7,8} via arithmetic operations {+,-,*,/}, exponentiation, and parentheses. Each number in the set must be used exactly once. Unary operations are NOT allowed (1 cannot be converted to -1 with without using a 0, for example). For example, the number 1073741824000000000000000 is obtainable via (((3+2)*(5+4))/6)^(8+7). I am a beginner with Mathematica. I ha

### Wolfram mathematica why is a wordcloud not generated in mathematica with this code?

All I get is this: WordCloud[{{"Afghanistan", Quantity[35623235, "People"]}, {"Albania", Quantity[3248655, "People"]}, {"Algeria", Quantity[37473690, "People"]}, {"American Samoa", Quantity[54719, "People"]}, {"Andorra", Quantity[85458, "People"]}, {"Angola", ..... And not any graphic

### Wolfram mathematica Mathematica; turn solutions of Nsolve into a list

I am using mathematica's Nsolve to solve a polynomial. When solved, Nsolve traditionally gives solutions like this: {{x -> 1}, {x -> 2}, {x -> 3},{x -> 4}} However, I need to transform this output into a list of numbers, so it looks like: {1, 2, 3, 4} How can I do this? There must be a simple way.

### Wolfram mathematica Correctly use Association in Mathematica to Apply Labels to Vectors

I have a matrix that holds multiple vectors with associated labels. The matrix looks something like this: inputseq2s={{0,2,4,6}->"A",{9,7,6,5}->"B",{5,6,4,3}->C}} I then map a function across the matrix like this: outtable2=Map[{#[],iterfunc[#[]]}&,inputseq2s]; But the output looks like this: {{A,{0,1,0,1}},{B,{0,0,1,1}},{C,{0,0,0,1}}} And I need it to look like this: {{0,1,0,1}->"A",{0,0,1,1}->"B",{0,0,0,1}->"C"} But I have thus far been unsuccessful at figuring o

### Wolfram mathematica Mathematica: How to evaluate this function?

I need to evaluate a function in 2D but it has three unknowns, the two arguments (x, y) and alpha. I need to evaluate x and y between {0,100}, while alpha between {0,1}. The function is: f(x, y) = x ^ (a) * y ^ (1-a) Thank you!

1    2   3   4   5   6  ... 下一页 最后一页 共 11 页