I am trying to do a plot of a time series with DateListPlot. I want to feed it a time series I obtain from an SQL database. When I retrieve the time series the list is composed of SQLDateTime entries that DateListPlot doesn't understand.
In[24]:= t=SQLExecute[conn, "select timestamp,value from timeseries order by timestamp asc"]
Out[...
My question is: why doesn't the following work, and how do I fix it?
Plot[f[t], {t, 0, 2*Pi}] /. {{f -> Sin}, {f -> Cos}}
The result is two blank graphs. By comparison,
DummyFunction[f[t], {t, 0, 2*Pi}] /. {{f -> Sin}, {f -> Cos}}
gives
{DummyFunction[Sin[t], {t, 0, 2 *Pi}], DummyFunction[Cos[t], {t, 0, 2 * Pi}]}
as desired.
...
I have data in the form { {x,y,z,f}...} I am using ListContourPlot3D but all I get is an empty box with dimensions -1,1 in each direction. Here is my code:
ListContourPlot3D[data5, PlotRange -> All, AxesLabel -> {"[Beta]", "[Omega]", "Vo"}, Contours -> {1500}].
These are the first 5 points of my data:( the whole set has 55 points)
{{200,...
How can I check if DatabaseLink`OpenSQLConnection was successful? My code is as follows
conn = OpenSQLConnection[JDBC["hsqldb", "file"], "Name"-> "test"];
Can I use something like Head[conn]?
...
This was a fascinating debugging experience.
Can you spot the difference between the following two lines?
StringReplace["–", RegularExpression@"[\\s\\S]" -> "abc"]
StringReplace["-", RegularExpression@"[\\s\\S]" -> "abc"]
They do very different things when you evaluate them. It turns out it's because the string being replaced in the ...
I have a CSV file that is formatted like:
0.0023709,8.5752e-007,4.847e-008
and I would like to import it into Mathematica and then have each column separated into a list so I can do some math on the selected column.
I know I can import the data with:
Import["data.csv"]
then I can separate the columns with this:
StringSplit[data[...
Lets say I have a function f[x_, y_], and two lists l1, l2. I'd like to evaluate f[x,y] for each pair x,y with x in l1 and y in l2, and I'd like to do it without having to make all pairs of the form {l1[[i]],l2[[j]]}.
Essentially, what I want is something like Map[Map[f[#1, #2]&, l1],l2] where #1 takes values from l1 and #2 takes value...
I'm going through some lecture notes, Fundamentals of Mathematica Programming (see the .nb file there). I'd like to be able to do the exercises right there in the notebook; but for some reason I can't figure out how to make the default cell an Input cell. In other words, when I'm clicking in that notebook to create a new cell--in the exe...
Is there a cleaner way to do the following, assuming that I have a reason to keep the data sets independent?:
x = {1, 2, 3};
y = {1, 4, 9};
ListPlot[Partition[Riffle[x, y], 2]]
Thanks!
...
Mathematica's list of built-in formats is pretty extensive; however, JSON is not on that list. Is there an existing solution for generating and parsing JSON in Mathematica, or are we going to have to roll our own solution?
...
Mathematica has a built-in function ArgMax for functions over infinite domains, based on the standard mathematical definition.
The analog for finite domains is a handy utility function.
Given a function and a list (call it the domain of the function), return the element(s) of the list that maximize the function.
Here's an example of fin...
Hi everyone,
I'm searching for an algorithm to calculate the average distance between a point and a line segment in 3D. So given two points A(x1, y1, z1) and B(x2, y2, z2) that represent line segment AB, and a third point C(x3, y3, z3), what is the average distance between each point on AB to point C?
I'm also interested in the averag...
Hi everybody, I'm currently reading the Mathematica Guidebooks for Programming and I was trying to work out one of the very first program of the book. Basically, when I run the following program:
Plot3D[{Re[Exp[1/(x + I y)]]}, {x, -0.02, 0.022}, {y, -0.04, 0.042},
PlotRange -> {-1, 8}, PlotPoints -> 120, Mesh -> False,
ColorFunction...
In Mathematica I have a list of point coordinates
size = 50;
points = Table[{RandomInteger[{0, size}], RandomInteger[{0, size}]}, {i, 1, n}];
and a list of cluster indices these points belong to
clusterIndices = {1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1};
what is the easiest way to split the points into two separa...
Consider the set of non-decreasing surjective (onto) functions from (-inf,inf) to [0,1].
(Typical CDFs satisfy this property.)
In other words, for any real number x, 0 <= f(x) <= 1.
The logistic function is perhaps the most well-known example.
We are now given some constraints in the form of a list of x-values and for each x-value, a pa...
I have a large matrix from which I would like to gather a collection of submatrices. If my matrix is NxN and the submatrix size is MxM, I want to collect I=(N - M + 1)^2 submatrices. In other words I want one MxM submatrix for each element in the original matrix that can be in the top-left corner of such a matrix.
Here's the code I have...
The following code returns 14 as you'd expect:
Block[{expr},
expr = 2 z;
f[z_] = expr;
f[7]]
But if you change that Block to a Module then it returns 2*z.
It seems to not matter what other variables besides expr you localize.
I thought I understood Module, Block, and With in Mathematica but I can't explain the difference in beha...
As was pointed out in a recent post scoping does not work as expected inside of Module.
An example from that thread is:
Module[{expr},
expr = 2 z;
f[z_] = expr;
f[7]]
(*2 z*)
But the following works almost as expected.
Module[{expr},
expr = 2 z;
Set@@{f[z_], expr};
f[7]]
(*14*)
What language design consideration made wol...
Hello everyone,
I am trying to solve the following implementation problem in Mathematica 7.0 for some days now and I do not understand exactly what is happening so I hope someone can give me some hints.
I have 3 functions that I implemented in Mathematica in a source file with extension *.nb.
They are working okay to all the examples. N...
FIRST PROBLEM
I have timed how long it takes to compute the following statements (where V[x] is a time-intensive function call):
Alice = Table[V[i],{i,1,300},{1000}];
Bob = Table[Table[V[i],{i,1,300}],{1000}]^tr;
Chris_pre = Table[V[i],{i,1,300}];
Chris = Table[Chris_pre,{1000}]^tr;
Alice, Bob, and Chris are identical m...