FAQ Database Discussion Community

Cannot create volume from Image3D function in Mathematica

arrays,image-processing,multidimensional-array,3d,wolfram-mathematica
I'm getting an error when using Image3D function of mathematica. I am trying to use that function to create a 3D volume from the array imagevar, which contains 10 grayscale binary images. images = FileNames["*.png"]; count = 1; Do[imagevar[count++] = Import[image], {image, images}] Image3D[imagevar[]] Whenever I run it, it returns...

How can I find the local minimum values and of a list in Mathematica?

list,wolfram-mathematica,minimum
I have interference images, and I have to calculate the visibility. For this I have to find the minimum and the maximum values of the intensity "oscillations". I've already found the maximums with the FindPeaks function, but I don't know how to find the minimums. img = Import["/home/martin/Dokumentumok/Egyetem/4. félév/Modern fizika...

Passing list as an argument in wolfram mathematica

list,arguments,wolfram-mathematica
I have a problem. I need to calculate the mean, but I don't understand why the code below doesn't work. I read the documention and this function should accept a list and return the mean value. What am I doing wrong? Why can't I pass a list to a function...

mathematica transpose does not work when using NumberForm and OutputForm

wolfram-mathematica,transpose
the code is like nwwa = List["#w#"]; nkka = List["#ks#"]; For[j = -4, j <= 4, j++, w = 16*(0.5 + 0.1*j); nwwa = Append[nwwa, w]; //calculate ks nkka = Append[nkka, ks]; ] Export["mathematica1.dat",Transpose[{OutputForm[NumberForm[nwwa, {3, 1}]],OutputForm[NumberForm[nkka, 6]]}], "Table"]; But I got the error: "The first two levels of {{"#w#", 1.6,...

How to write a showIt function in Haskell?

In Mathematica, ShowIt function is commonly used for debugging. Basically, ShowIt is an identity function that prints the value of its parameter to the console. I wonder, how it is possible to write the same function for Haskell. The issue with Haskell is that since the function does IO, it...

Plot error band using functional form

wolfram-mathematica
I have a data set with x,y and error(y) values. I write this in mathematica as: Needs["ErrorBarPlots"] data = {{{0, 0.10981309359605919}, ErrorBar[0.05240427422664753]}, {{0.2145, 0.09146326059113304}, ErrorBar[0.034195343626358385]}, {{0.4290, 0.08230438177339898}, ErrorBar[0.02533205817067696]}, {{0.6435, 0.0768141842364532}, ErrorBar[0.020205473852635995]}, {{0.8580, 0.07223473349753692}, ErrorBar[0.016156209168991867]}, {{4, 0.056122650246305375}, ErrorBar[0.009288720442961331]}}; ErrorListPlot[data, Frame -> True,...

pattern matching in pure functions

wolfram-mathematica,wolfram-language
I need to define a pure function that takes two arguments and returns their quotient. If the divisor is 0 then I want to return 0. If I had a named function then I would do div[_, 0] := 0 div[x_, y_] := x / y how to do the...

Mathematica 2D limit computation

wolfram-mathematica,limit,wolframalpha
Wolfram Alpha and Mathematica (on my laptop) give zero for the limit shown in the image below. This is okay if x and y approach the origin along the path y = x. But what happens if x and y approach the origin along the path y = x^3? I...

Blur a matrix using Fast Fourier Transforms

c++,wolfram-mathematica,gaussian,convolution,fftw
I want to blur values in matrix, so that in neighboring elements we'll not have sharp transitions. From the Wikipedia page Gaussian Blur I've found some info on Gaussian blurring. I've tried it with the most simple algorithm, and, hence the run-time was too long. Frankly, I'm not sure if...

Convert mathematica functions to lua

parsing,lua,wolfram-mathematica,translation
I want to read files written using the Mathematica function 'Save'. Inside, their are expressions that I would like to translate in lua. For example: mathematica -> lua foo[bar_]:= a*bar + b -> function foo(bar) return a*bar + b end foo[bar_]= a*bar + b -> foo[bar] = a*bar + b...

Wolfram Mathematica Recurrence Table

wolfram-mathematica
Good evening, I have a problem with Wolfram Mathematica and I would be grateful if someone could help me and post the solution. Here's the exercise: Print first 11 elements of the sequence a which is given with this reccurence relation: a(n+1) = 11a(n), where a(1) = 7, in which...

Mathematica Dynamic List Design [closed]

dynamic,graphics,slider,wolfram-mathematica,list-manipulation
Suppose a dynamic list of 5 that if one changes, all the others would change correspondingly to keep the sum 1. It comes from a practical problem that 5 probabilities of a total of 1, if one of them changes (by Slider), all the others will also change in an...

Perl - Regex line that starts with “Out[1]=”

regex,perl,wolfram-mathematica
I have a Perl script to capture Mathematica output, but am trying to find a good way to just catch the line starting with "Out[1]". I thought I would just check if ( \$line =~ /^Out[1]=/ ) What am I doing wrong? Code is below, and then output of program...

Mathematica Order of an Equation

order,wolfram-mathematica,equation
Is there a way to obtain the order of an ODE in mathematica. For example, if i have y''+5y i want mathematica return 2 (beacuse it's a 2nd order equation). So, is it possible what i'm asking? ...

Highlighting intersection points of 2 functions (Mathematica)

plot,wolfram-mathematica,intersection
Given two functions, I need to find their intersection points and show them on the graph. For this particular problem, the functions are: f(x) = - (x - 2) ^ 2, g(x) = x/(x+1). So far, I have the following: Plot[{-(x - 2)^2 + 4, x/(x + 1)}, {x, 0,...

Basic Gamma functions identities not verified with Mathematica

wolfram-mathematica
Mathematica V10 does not return True to the following lines of code: Simplify[Gamma[z] == (z - 1)!, Element[z, Integers] && z > 0] Simplify[(Gamma[1 - z] Gamma[z]) == Pi/Sin[ Pi z] , Element[z, Complexes] && (0 < Re[z] < 1)] As I cannot believe that MMA10 does not know about...

Feasible solutions to inequations

matlab,wolfram-mathematica
I have a Math problem where I have some true statements, and I want to know if there is a feasible solution to an equation. I would like to know how to do that in either Matlab or Mathematica. The true statements are: 0 < a, b, c, d, e...

How can I define an abstract odd function in mathematica? With respect to derivatives

wolfram-mathematica
I want "to work symbolically" but not only with function but with derivatives. For instance I would like f'[x] - f'[-x] to be simplified to zero. Comment: Neither of the ways, suggested here, did not help me....

Extracting coordinates from a Mathematica spline graphics

wolfram-mathematica
How can one extract the coordinates of all the points which make up the following graphics (here just an example)? spl = BSplineCurve[{{-.4, -.3}, {0, -.6}, {.4, -.3}, {0, -1.2}}, SplineClosed -> True] ; Graphics[{Red, Thick, spl}] The problem is that if I add //FullForm to the last line there...

Matlab equivalent to Mathematica's FindInstance

matlab,wolfram-mathematica,solver
I do just about everything in Matlab but I have yet to work out a good way to replicate Mathematica's FindInstance function in Matlab. As an example, with Mathematica, I can enter: FindInstance[x + y == 1 && x > 0 && y > 0, {x, y}] And it will...

Indefinite integral not evaluated in Mathematica

wolfram-mathematica
I have an Indefinite integral integral: Rm = 50; d = 3; W = 1.2; f = 1/(1 - R^2/Rm^2) A = W*(d - 1 + X)/d*R^(X - 1) - R*f - (1 - d)/R; B=W/d*R^X + 1; Integrate[A/B, R] Mathematica evaluate the above mentioned integral only for X =...

Direct replacement within a function body of arguments such as the symbols >, <, !=, ==

wolfram-mathematica
Let' s suppose I call a function with the Greater symbol ">" an argument: findb[x^2 - 10, ">", 0] Instead of testing within the function body what the second argument is (the usual design) I want it to replace directly every expression where it appears: findb[exp_Plus, ptest_String, value_?NumberQ] := Module[{},...

Enable Frames for All 2D Plots in Mathematica

wolfram-mathematica
To set all the 2D plots to have the option Frame->True, i added the following to my "init.m": (SetOptions[#, Frame -> True]&)/@{Plot,ListPlot,ListLinePlot,LogPlot,LogLogPlot,LogLinearPlot}; Which seems awkward and i never have all the different plots in the list. Is there a simpler/better way for me to set these options en masse? Thank...

A list of variables used by Wolfram Mathematica function

wolfram-mathematica
Is there a way to get a list of variables used by a function? For example: a=1; b=2; f[x_]:= 2a*x+b; Needed: SomeFunction[f] Output: {{x},{a,b}} The parameters of the function ({x}) are not really mandatory. Thanks....

Java JBoss Fatal error: cannot find the required native library named JLinkNativeLibrary

java,jboss,kernel,wolfram-mathematica
I'm trying to work with Wolfram Mathematica Kernel from Java Web Application using JBoss. Here is a Main Class. public class Main { static KernelLink ml; static KernelLink ml2; public Main(){ String path = "-linkmode launch -linkname 'C:/Program Files/Wolfram Research/Mathematica/9.0/MathKernel.exe'"; try { ml = MathLinkFactory.createKernelLink(path);// подключаем ядро ml.setComplexClass(MyComplex.class); System.out.println(ml.getComplexClass()); ml.discardAnswer();...

how to convert contour plot from mathematica to matlab

matlab,wolfram-mathematica,matlab-figure,contour
I am trying to draw a contour for an equation which I got from Mathematica. I was able to draw this contour easily in mathematica but not on matlab. Kindly suggest. b=linspace(0.0005,0.0010,100); c=linspace(0.64,0.7,100); z=(-136*power(2.718281828459045,power(88682,c)*b)*(1 - 1/power(2.718281828459045,1*power(88682,c)*b)))/(-1+ power(2.718281828459045,power(88682,c)*b)) - 1*(power(3,c) + power(33,c) + power(146,c) + power(227,c) + power(342,c) + power(351,c) +...

Display graph of x versus number of prime factors of x

wolfram-mathematica,wolframalpha,wolfram-language
I am trying to get wolfram alpha website to display a graph where you have x on one axis and the number of not necessarily distinct prime factors on the other axis. I tried this query: plot f(x) = number of factor x Did not work. How can I do...

Convert Mathematica equations into R code

r,latex,wolfram-mathematica,mathml
Is there an easy way to convert Mathematica equations into R code? I have several equations that consist of dozens of terms with subscripts, superscripts, and greek letters. For example, here's a small part of one equation in Latex format: m_2_2= 48 b_1 c_2^2 d_1 \rho ^4+48 b_2 c_1^2 d_2...

Product a scalar with a matrix in mathematica

matrix,wolfram-mathematica,product,scalar
I want to product a scalar with a matrix in mathematica. My codes are : w.P + (w^3).P P is a matrix and w is a scalar, but product gives scalar out of the matrix. Why?...

How to skip warnings in a loop [wolfram-mathematica]

wolfram-mathematica,wolfram-language
My goal is to read in data on all the available stocks at NASDAQ using FinancialData[], and do some computations on it. The problem is (I already contacted the support because of this and it is a known problem), that if I use Slist = FinancialData["NASDAQ:*", "Lookup"]; to readin all...

Sage hangs when calling Mathematica

python,wolfram-mathematica,sage
I recently installed Sage 6.3 on my Fedora 21 machine. I'm using version 6.3, which is slightly outdated, because it is the most recent thing available in yum's repositories. I also installed Mathematica on the same computer in the hope of being able to call it from within Sage. Mathematica's...

Solving system of non-linear equations in Mathematica

wolfram-mathematica
I am trying to numerically solve the below system of six equations (g0-g5) for a0-a5 in Mathematica. I am no expert in Mathematica and am not entirely sure how to do this. f[x_, y_] := Exp[a0 - 1 + a1*x + a2*y + a3*x*x + a4*y*y + a5*x*y] g0[x_, y_]...

Mathematica: difficulty using Multinormal Distribution and InverseCDF functions

statistics,wolfram-mathematica,normal-distribution,cdf
I'm struggling to use the functions MultinormalDistribution and InverseCDF in MultivariateStatistics package. Essentially << MultivariateStatistics` sig = .5; u = .5; dist = MultinormalDistribution[{0, 0}, sig*IdentityMatrix[2]]; delta=InverseCDF[dist, 1 - u] The output is InverseCDF[ MultinormalDistribution[{0, 0}, {{0.5, 0}, {0, 0.5}}], {0.5}] can someone correct the above code? If I've understood...