« first day (1001 days earlier)      last day (1882 days later) » 

12:05 AM
@Rojo You're a clarinist
@belisarius A clarinist vulture oligarch gorilla patriarch dictator santa claus
@Rojo But are you Nordic or Surdic?
@belisarius Zurdic
(not really)
@Rojo Oh, you should. No matter what, the right here is Seineldin-alike
12:22 AM
I am trying to understand ListPlot3D with 4 elements, I cannot understand what the fourth element is:
How many points do it have? 2 points or some combination?
Can someone explain please?
@hhh From the docs: "ListPlot3D[array]: Generates a three-dimensional plot of a surface representing an array of height values." It assumes that the height at position (x,y) is given by matrix element (i,j) and then interpolates between these points.
I need an easy example. Which values determine (x1,y1,z1) or (x4,y4,z4) in the example above?

ListPlot3d[{{x1,x2,x3},{y1,y2,y3},{z1,z2,z3}}] <--- it is easy to understand this but the above has totally different format :/
What is matrix in the above example?
@hhh The matrix is {
So the height at {2,4} is 2 and it is 1 at every other (integer) point.
12:38 AM
Where did it get 4? Are index numbers implicitly defined here?
@hhh Yes, in the way that I described earlier.
2 is the row number, 4 is the column number.

Do I need to get 16 points or 8 points? I want to get from here to this form {{x1,y2,z3},...{xN,yN,zN}}.
@hhh I'm sorry but I don't follow? 16 points or 8 points for what?
There are many different ways to go from such a matrix to the other representation that you mention. This one is conceptually simple: dims=Dimensions[m]; Table[{i,j,m[[i,j]]},{i,dims[[1]]},{j,dims[[2]]}] where m is your matrix.
1:26 AM
Thanks @Pickett ! I got it, I had to put my mind to something random and think this again, yeah now I understand it -- it is basically just traversing the matrix :)

I am trying to visualise this kind of data where (time, x,y,z,). I can plot (x,y,z) with ListPlot3D but I cannot understand how to do it over time, some ListPlotTimePlot?

@hhh It comes down to what kind of result you expect. What you want the final visualization to look like.
My goal is to visualise Spinning ball over time (I have acceleration, gyro, magnetometer) I have no idea yet how to characterize spin.
(time, accX,accY,accZ)
@hhh OK, so you want to create an animation/movie then, right? One where each frame shows a position of the ball.
I used Sensor Kinetics software in iPhone and downloaded data from it and now I would like to see RPM over time -- I want to see flight path of my phone in Mathematica. I find this fascinating :)

I don't know yet whether Quaternions help here at all, totally newbie in this :)
You need to create a function that takes as its input {time, acceleration, gyro, mag} and returns a frame. Then you'll map this function over your list of data to retrieve all frames, and then you'll turn these frames into an animation using ListAnimate or Export.
I'm not sure exactly what data the gyro and the magnetometer encode, but I guess it's rotation and something else right? If you want to visualize rotation then ListPlot3D is not a good choice, in my opinion. I would go with Graphics3D and Sphere.
1:41 AM
I did an example of this 3 years ago in Android with Verlet integration for the location of the ball, en.wikipedia.org/wiki/Verlet_integration. I cannot remember why I used Verlet integration that time, some numerical method.
3D Verlet Integration: youtube.com/watch?v=AMJiolnFxHE
Well, there are many easy integration schemes that you could use. But if you want to leverage Mathematica you could try to use Interpolation on your data and then NIntegrate.
I want to use the simplest method :O
Is Verlet integration like NIntegrate? NIntegrate is also a numerical integration but do we know which one?
No, we do not know, but NIntegrate will use something else since it operates on a continuous function and therefore is at liberty to sample as it wishes. But that is the crux; if you want to use NIntegrate you have to interpolate the data first.
I can't tell what would be easier for you; to wrangle with the built-in functions or to implement a suitable integration method, such as Verlet integration.
And I need to do some smoothing also with pikes...
I need to smooth, interpolate and then NIntegrate ---1 time ---> velocity ---2 times ---> position
I don't think you should smoothen acceleration data, to be honest.
I don't know what your data source is but typically - unless we are talking about an object in free fall - the acceleration is not constant. It comes from collisions etc.
1:59 AM
It looks like this: pastebin.com/DLhpvnYv
Going to pretty much to one direction
What I'm saying is that collisions etc. create peaks. So typically you would expect acceleration data to have peaks. If you smoothen those peaks away you lose important information, so generally I would advise against that. But the decision is yours.
2:16 AM
8 hours later…
9:54 AM
@hhh My solution wasn't plug and play since I haven't done this before. Just some thoughts to consider. I don't think integration from acceleration to position data in three dimensions has been covered on the site yet, so I think it would be great if you would ask this question. But remember that other people will read the question and the answers in the future, so make it good. Don't confuse by asking other questions i.e. regarding visualization at the same time. Include your data.
2 hours later…
12:12 PM
Can I have some upvotes on this question please, so that I can invite the use into chat?
Q: How to create a 1D vector by selecting a straight line in a given angle of 2D array

Asaf MironSuppose I have an image created by the code provided below. I want to select a line (1D vector) $ \left(y-y_{0}\right)=n\left(x-x_{0}\right) $ from the output image (2D matrix) by specifying $n$ and $\left(x_{0},y_{0}\right)$. Can anyone explain how to do this? Code: w1 = 600; w2 = 600; mask ...

Ah.. never mind. I could upvote his other question.
Thanks :)
Anyhow, do you manage to get an image of the 1D vector?
@AsafMiron Hi.
Hello! first of all thank you very much for your help
@AsafMiron Ok, here is your code where I only added some semicolons and spaces:
I can't see it
12:21 PM
@AsafMiron Hehe.. haven't copied it yet :-)
w1 = 600; w2 = 600; mask =
    Re[Exp[I 56 k] DiskMatrix[20, {w1, w2}]], {k 100, k 200}], {k,
    2}] + Re[Exp[I 5] DiskMatrix[20, {w1, w2}]] +
    Re[Exp[I 5 k] DiskMatrix[20, {w1, w2}]], {k 200, k}], {k,
    1}]; Image[0.5 mask, Magnification -> 1] ;
 ft = (Re[Fourier[mask]])^2;
 ift = Image[
     ft, {w1/2, w2/2}]\[TensorProduct]ToPackedArray[{1.0, 0.3, 0.1}],
   Magnification -> 1];
 bresenham[p0_, p1_] :=
  Module[{dx, dy, sx, sy, err, newp}, {dx, dy} =
?! why doesn't my version work?
This one works great
@AsafMiron You have to take care of some things:
You have to check that the backslash in \[TensorProduct] gets not eaten during copying.
You have to check that (if you don't end a line with ;) you are not accidentely using implicit multiplication.
@AsafMiron Those two things and the {0,0} as point where the only errors I have fixed.
@halirutan Maybe I could ask for some general advice? I'm now starting my physics graduate studies and have little experience with using a computer to carry out calculations. Could you direct me to a good comprehensive tutorial or book to explain how exactly this whole thing works?
@AsafMiron There are two resources which are sufficient to reach a very advanced level.
@AsafMiron First, we have here the original book of David Wagner which we were allowed to scan and to publish on this site.
@halirutan also, in the code, I don't understand how the point {1,1} is defined. Does it refer to the pixel at {1,1} of the matrix? If so, where does the line originate from?
12:31 PM
@AsafMiron This is one of the greatest books I have ever read about Mathematica. Pretty old, but it contains everything you need to know from the core language.
@halirutan, I'm downloading as we speak :)
@AsafMiron Second, we have here the free book of Leonid Shifrin. He is one of the high-reputation members here and has a very deep knowledge about Mathematica.
@LeonidShifrin Speaking of the devil :-)
@halirutan Oh yeah :)
@halirutan But this is certainly an exaggeration :)
@LeonidShifrin Nope, I don't think so.
@halirutan I've downloaded both books and will be going over them soon. Thank you
12:37 PM
I haven't read it from cover to cover, but the "Mathematica Navigator" by Ruskeepaa seems pretty good if one looks for a balanced view (programming vs applications)
@AsafMiron About this...
Those are coordinates of the pixel matrix.
@AsafMiron You can simply try it:
m = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Extract[m, {1, 1}]
Extract[m, {2, 1}]
Extract[m, {2, 3}]
@halirutan I see... Okay, so bresenham[p0_, p1_] takes, for example, {1,1} and how doesn it know which direction to continue in?
and @Leonid Shifrin, thanks, I'll try to find that one too
@AsafMiron It takes 2 points and uses the line between those two points. If you need direction, you have to make a transformation. What exactly do you need in your application?
@AsafMiron No problem. Hope you'll find it helpful.
@halirutan In the code, don't I only feed it one point (i.e. {1,1})? I'm trying to write a demonstration of an optics system that uses the discs as apertures, which after diffraction results in the Bessel diffraction pattern and then I want to take a line directing along one of the directions from the central disc to one of the other discs and fourier transform along it so show that I get 2 slits
12:50 PM
@AsafMiron No, for the main diagonal line of the image I used {1,1} and the most extreme corner of the image which happens to have the coordinates ImageDimension[img] :-)
@AsafMiron So you could call just bresenham[{12,23},{102,2}] if you like and you get the line connecting those two points.
@halirutan Great, now I understand, you actually used 2 points. Also, do you perhaps have an idea on how I can more easily create the discs? It would be far easier to work with if I could just write down where I want them to be centered than use the code I now have and don't really understand
@AsafMiron Yes, I think I have a slightly better idea. Let me see..
@AsafMiron So you only need disks with a certain brightness, radius and position?
I think so, brightness translates to phase difference right? I need them all to have the same radius and to be able to select where I want them centered
@AsafMiron Yes, I guess this is what the Re[Exp[I 56 k] DiskMatrix[20, {w1, w2}]] is doing.
@halirutan Yup. So I guess the only control I need over brightness is via the complex exponent
1:04 PM
@AsafMiron OK, I talk to you later. I need to go for a while. I ping you here then..
@halirutan No problem, Thanks for the help!
2:02 PM
@Pickett ok I added it as a question here, I find it also intriguing how people solve it and probably useful for future users as well, thank you for your inspiration :D
2:23 PM
@hhh You may want to add where the acceleration data comes from as well. This might help to alleviate concern whether interpolation is at all reasonable. (For example for a roller coaster I would consider it reasonable, for a billiard ball I would not.)
2:39 PM
@halirutan Also, you said something about the image and the matrix being reversed in relation to one another? Could you please elaborate why and how do I fix it?
3:21 PM
ImageData[img, DataReversed -> True]
@blochwave So will adding DataReversed -> True fix it?
4:02 PM
@AsafMiron It can, but it doesn't has to confuse you. It depends. What do you think is the pixelposition {1,1} in the following image?
@AsafMiron I mean which corner
upper left?
@AsafMiron Then you are fine..
great :)
@halirutan Regarding the circles, do you have any idea?
4:04 PM
Because most people map a usual Cartesian system on an image where the origin is in the lower left corner.
@AsafMiron yep, but I was away until a few minutes ago. I'll have time after dinner.4
But since this is a matrix it would be funny to think of it otherwise
Question... Is my question which I ask, mathematica.stackexchange.com/questions/63210/…;, really hard to do?
@halirutan Great, It'll really help if you could show me a more intuitive way
@WG- You want
plantstate /. Rule @@ plantinput
First, Replace is wrong because it tries to transform the entire expression expr as the documentation states. You want ReplaceAll which is /.
Second, your replacement rule was wrong because what you tried had the following form (and would have led to an incorrect result):
x + uk /. uk -> uk == blub
thank you Halirutan for your explanation.

I am new to Mathematica and not yet familiar with all the concepts of the language and all of the functions.
4:11 PM
@WG- No problem.
@AsafMiron Still around?
Never mind.. this is too slow anyway. Later!
3 hours later…
6:57 PM
@AsafMiron OK, I guess I have a function which is quite fast and easy to use.
makeMask[disks_, r_, {ny_, nx_}] :=
 With[{dm = Position[DiskMatrix[r], 1] - (r + 1)},
  Plus @@ (Function[{pos, value},
       Select[(pos + # & /@ dm),
         1 <= First[#] <= ny && 1 <= Last[#] <= nx &] -> value, {ny,
        nx}]] @@@ disks)
Looks a bit dense, but it's easy to use:
makeMask[{{{40, 50}, 10}, {{300, 200}, 15}, {{400, 500},
     30}, {{600, 500}, 10}}, 20, {600, 600}] // Image // ImageAdjust
@Kuba Hi.
is this suppose to happen?
SetAttributes[test, HoldAll];
test[a_] := DynamicModule[{x},

x = 100;

sorry, not that
SetAttributes[test, HoldAll];
test[a_] := DynamicModule[{x},

x = 100;

@halirutan hmm? :)
@Kuba Hmm... I would say we should look at the trace, but you get sick when you see the output..
7:12 PM
@halirutan well, probably it is working along with how all those replacements of names are working
I don't ccare :P I'm just curious if it is a really good idea to keep such design
It won't be a problem if you are in deeper context but on top it is at least unintuitive.
@Kuba I would say it's an error in the scoping of DynamicModule and it shouldn't happen at all.
@Kuba I mean you can easily trick Module too to make weird things and we have discussed the incomplete scoping many times..
SetAttributes[test2, HoldAll];
test2[a_] := Module[{x}, a]

@halirutan the difference in your case it is not common way of naming variables linke x$, or it is less common than just x :)
@Kuba I love dollars, don't you?
@halirutan aren't you in Germany? ;P
It's like creating a hacker name... you simply put x's around and you are super cool
7:22 PM
@halirutan do you remember any topic about that, or should I create it. I don't need any answer, just for "beginners" to be aware of that
@Kuba Yep, but I guess if you can get some millions for free, it doesn't matter whether it is Euro or Dollar..
@Kuba Puhh... I guess much of it happened in chat but let me have a quick look..
@Kuba For one, there is this answer for renaming conflicts in scoping constructs..
@halirutan At the beginning when I was not aware of Attributes but in hurry to do something, I was just using Unevaluated, Hold and friends to mimic this behaviour. It seems it was safer :P,
@Kuba But that wouldn't save you here either:
test2[a_] := DynamicModule[{x}, a]
x = 100;
Here, you get 2 Dollars for free. We should make a product out of that and we are rich in no-time.
@halirutan Ah, I should've mailed you, now everyone knows how. We should hurry!
@Kuba too late
7:38 PM

test2[a_] := Module[{x},
  Hold[Set][a, 7] // ReleaseHold;]

x = 100;

2 hours later…
9:08 PM
Can anybody tell me how you can Expand a symbolic matrix calculation?
I have


plantinput =
ut[k] == (IdentityMatrix[nip] - mGamma).ut[k - 1] + mGamma.u[k]
controloutput = u[k] == G.w[k] + H.et[k]

s1 = Expand[plantinput /. Rule @@ controloutput]
and I get

ut[k] == mGamma.(G.w[k] + H.et[k]) + (-mGamma + IdentityMatrix[nip]).ut[-1 + k]

Instead of

ut[k] == mGamma.G.w[k] + mGamma.H.et[k] + (-mGamma +
IdentityMatrix[nip]).ut[-1 + k]
10:04 PM
@halirutan Thanks for not forgetting about me! I will check it out first thing tomorrow morning and let you know. Your help is greatly appreciated!
10:53 PM
@AsafMiron You're welcome.
Oh man, the word ugly isn't really enough. In V10 with the new fonts, it looks like a bird pooped on the code:

« first day (1001 days earlier)      last day (1882 days later) »