Subject: (**) comments highlighted - newbie I hope my question is not completely silly, but I have been trying to find an answer for this both in the Mathematica book, in this forum's archive and elsewhere on the net and I failed. Since I will be doing quite a bit of programming with Mathematica in the near future, I would like to have the following (very reasonable, I think) feature: comments (* ... *) should (by themselves :) ) change colour (for instance) so that they are obvious in the code from a distance. I hope the solution to this is not very complicated, and I'm sure I am not the first to think about this. Can anyone help? Adrian === Subject: Re: using iFFT on a Continuous Time Transfer Function Vin, if you have an analytic expression why not try InverseFourierTransform. Go to Help Browser, look in Algebraic Computation -> Calculus -> InverseFourierTransform. Mariusz I know what my signal looks like in the frequency domain, because I have a analytic expression for that (i.e., a function of frequency). I don't have a time domain counterpart though, but I expect it to be a real valued pulse-like signal, lasting a few nanoseconds. I am wondering, can I somehow apply the IFFT to this frequency domain function to get a discrete time representation of the time domain counterpart? If so, any hints as to how to go about it? I have already tried sampling my frequency domain function to produce something like the output of a FFT, e.g., with the -ve frequency function values being generated from the complex conjugate of the positive frequency function values etc. However, when I apply the IFFT, I get nothing like what I expect. Vin === Subject: Matrix and estimation stuff 1) Lets say i have 2 variables, the x, y coordinates of 2 points. How am i going to compute the covariance matrix of the 2 points? 2) What exactly is a jacobian matrix about? I understand how to derive a jacobian matrix from a given process equation but i do not really understand the usage/purpose of it. 3) If i got a nonlinear process, how do i linearise it? Has this got anything to do with the jacobian matrix above? rgds, jax === Subject: NDSolve, coupled equations, different number of variables I am trying to numerically solve a set of two coupled equations. I'll describe how they come about to motivate this. I have a harmonic oscillator (z''[t] + gamma*z'[t]+(omegbarmod[T])^2*z[t] == 0). However, the spring constant of that oscillator depends on its temperature (omegabarmod is a funtion of T: omegabarmod[T]). The temperature of the spring depends on the heat flow into the spring, which depends on the position of the oscillator. Using the 1-D heat equation with boundary/initial conditions: D[T[x, t], {t, 1}] == tdiff*D[T[x, t], {x, 2}], T[x, 0] == 0, T[0, t] == 0, (D[T[x, t], {x, 1}] /. x -> barlength/2) == heatin[z[t]] So, the position of the oscillating beam governs the heat input, which is a time-varying Neumann boundary condition on the homogenous heat equation governing the temperature of the bar, and the spring constant of the oscillator is a function of the temperature of the bar at its center. If I try: result = NDSolve[{D[z[t], {t, 2}] + gamma*D[z[t], {t, 1}] == -(omegabarmod[T[barlength/2, t]])^2*z[t], D[T[x, t], {t, 1}] == tdiff*D[T[x, t], {x, 2}], T[x, 0] == 0, T[0, t] == 0, (D[T[x, t], {x, 1}] /. x -> barlength/2) == (1 - E^(-t/(Pi/10^8)))*heatin[z[t]]/2, z[0] == initialposition, (D[z[t], {t, 1}] /. t -> 0) == 0}, {z, T}, {t, 0, numperiods*2*Pi/omegadrive}, {x, 0, barlength/2}]; (with all of the constants and the functions heatin[T] and omegabarmod[T] defined previously, or course) I get: NDSolve::derlen:The length of the derivative operator Derivative[1] in z'[t] is not the same as the number of arguments Basically, it looks like it will not let me solve a system of equations where z is a function of t only and T is a function of x and t. I have also tried using the total derivative Dt in place of D for the oscillator equation, but I get the same result. I've run a bunch of test cases where I put independent equations and boundary conditions into NDSolve. It only solves them if they are functions of the same number of variables. Then I couple them together in some way, and it still solves them. So, the problem really seems to be that I can't solve for z[t] and T[x,t]. I have spent a lot of time trying things like making z[x,t] a function of both x and t anyway, and trying to set up the boundary conditions in a way that makes z essentially independent of x. If I decouple the equations and use z[x,t] and T[x,t], it solves them, giving the solution that z is independent of x, which would be fine. However, when I couple the equations again, I get underdetermined or overdetermined system errors. If you have any ideas on how to pose this problem to Mathematica I'd appreciate your help. Stergios === Subject: Integral of a bivariate function For a given bivariate function I want to calculate the integral of the function over an arbitrary compact region A, for instance over A={(x,y)| f(x,y)=c} for some constant c. The function is smooth and in my application it is the joint density of two continuous random variables. I wonder if this can be done in Mathematica and in that case how. Otherwise I'd appreciate any pointer to other programs which can be used for this. === Subject: Substitution ignored? Why is the following going wrong? f = x^2 Plot[{ f, f /. x->x-1 }, {x,0,2}] (* Identical functions plotted !!! *) g = f /. x->x-1 Plot[{f, g}, {x,0,2}] (* OK, different functions plotted *) -- Jos === Subject: Creating combinations from a group of sets, PART 2 the recent msg[48679] on combining elements from a group of sets has reminded me that I always wanted a Table[] command that would step through lists instead of using iterators. For example, my NewTable[ ] command would be used something like this: NewTable[ (i+j)/(m+n),{1,2,3},{5,10.15.20},{3.14,1,414,0.707},{faith,hope,charity}] Somehow, magically, the first list would be associated with i, the second list with j, etc... Of course, all this could be accomplished, by this Mathematica code: a={1,2,3}; b={5,10.15.20}; c={3.14,1,414,0.707}; d={faith,hope,charity}; Table[ ( a[[i]] + b[[j]] ) / ( c[[m]] + d[[m]] ),{i,1,Lengh[a]},{j,1,Length[b]},{m,1,Length[c]},{n,1,Length[d]}] but that's a lot of typing. ---------------------------------------------------------------------------- --------- So here's my first attempt at a NewTable[] command using Distribute[] as suggested in responses to msg[48679]. It assumes that the first expression in NewTable[ ] is a pure function. Clear[a,b,c,d,e,f,g]; NewTable[f_,h___]:=f /@ Distribute[{h},List] and here it is in use: In[]:=table[#[[1]] + #[[2]]^#[[3]] & , {a, b, c}, {d, e}, {f, g}] Out[]:={a + d^f, a + d^g, a + e^f, a + e^g, b + d^f, b + d^g, b + e^f, b + e^g, c + d^f, c + d^g, c + e^f, c + e^g} This has the nice advantage of working with any number of lists. I just wish I could get rid of all the double bracket typing! ---------------------------------------------------------------------------- ------------- I'm not sure I can even figure out how WRI has programmed the regular Table[] command. What would the code for Table[] look like? john kiehl === Subject: Re: LogIntegral^(-1) I tried your approach. Works about the same as mine. what works is setting the solution equal to y and solving for t which reinverts the ArcLogIntegral... The soltion looks like a square root function or the other way a parabolic function. Anyway a function like: s[t_]=y=a+t^s for s in the range of 1/2 or 1/3 about. > reply. >>The InverseFunction wrapper means, not surprisingly, that it is an >>inverse function. Not a reciprocal (which would be written in >>OutputForm as LogIntegral[...]^(-1) rather than LogIntegral^(-1)[...]). > This is not a real clear distinction > and I've never seen it in any of > my Mathematica books or software, so thans for giving me that! > I frankly would rather it was ^(-1) instead of an inverse function. > It's not the kind of result I had hoped for. > But I'm glad I did get a reply. >I really need to know if this is: >Li(x)^(-1) >or >ArcLi(x) >since it makes a great difference and Mathematica notation on this >seems unclear. >>It's very clear. >>n[t] = s[t]/(Exp[D[s[t],t]/w]-1); >>n1[t_] = FullSimplify[D[n[t],t]]; >>In[10]:= InputForm[soln = DSolve[n1[t]==0, s[t], t]] >>Solve::ifun: Inverse functions are being used by Solve, so some >>solutions may >> not be found; use Reduce for complete solution information. >>InverseFunction::ifun: >> Inverse functions are being used. Values may be lost for multivalued >> inverses. >>Out[10]//InputForm= >>{{s[t] -> (-1 + InverseFunction[LogIntegral, 1, 1][ >> E^(C[1]/w)*w*(t + C[2])])/E^(C[1]/w)}} >>The InverseFunction wrapper means, not surprisingly, that it is an >>inverse function. Not a reciprocal (which would be written in >>OutputForm as LogIntegral[...]^(-1) rather than LogIntegral^(-1)[...]). >One approximation ( Euler's I think) of the distribution of primes is >Pi(n)=Li(n)--> n/log(n): asymptotic >>This is a bit misleading. Pi(n) is approximated by Li(n) but they are >>not equal. >[...] >>Daniel Lichtblau >>Wolfram Research === Subject: Re: Exporting 3D plots ops--> other people's stuff Gee, I don't know? Remember Math world was gone for a year or so? ops is hard to deal with... You got to tell people where you got the neat stuff or it comes back on you. It ain't yours... you didn't do most of these images yourself. > MathGL3d can export RIB's > http://phong.informatik.uni-leipzig.de/~kuska/mathgl3dv3/ > my development version exports OBJ too but you should send me a mail > if you need this. > >>Is there a way of exporting 3d plots to a format like .obj or .3ds >>which can be opened in a 3d package. I can also work with renderman >>.rib format if that is easier. >>Dag === Subject: Re: How to plot a direction field? Chris, Several ways to do this. You can use PlotVectorFields but I think the best way to do this is to use Selwyn Hollis's stuff for differential equations. He has a nice set of notebooks for this stuff at: http://www.math.armstrong.edu/faculty/hollis/mmade/ Good luck. Cliff >Hi: >My TI-89 can plot the direction field of a differential equation using >little line segments in the XY plane. >How to do this in Mathematica? >So far I see only PlotVectorField. === Subject: Re: Merging lists if an element in each partially matches? Hi Charles, If you can convert all of your sample names to strings, the following simple approach might be sufficient--it's hard to tell exactly what you need from your message. In[1]:= nameList={3_78457,3_78457_5} Out[1]= {3_78457,3_78457_5} In[2]:= nameList[[1]] Out[2]= 3_78457 In[3]:= partialMatchQ[l_String,m_String]:=If[Union[StringPosition[l,m],StringPositio n[ m,l]][Equal]{},False,True] In[4]:= partialMatchQ@@nameList Out[4]= True > I typically need to merge separate sets of data into one list. If > each file contains the same sample I can join them quickly and easily > using various merge and sort routines that have been discussed here in > the the past, such as myMatch5, etc. This is great when the sample > name match exactly, however I am attempting to deal with sample names > that do not match exactly. They will differ only in the length of > name; one list may contain for example a sample name of 3_78457_5 and > the second may only have 3_78457 or 78457_5. > It should be possible to search the 2 data lists for columns that have > the largest run of consecutively matching characters, and assume that > is the correct match. Would it be possible to develop a similarity > criteria? I can see that this type of function would very useful in > things more important that this. > Any suggestions greatly appreciated. > Charles Koehler === Subject: Re: Merging lists if an element in each partially matches? > I typically need to merge separate sets of data into one list. If > each file contains the same sample I can join them quickly and easily > using various merge and sort routines that have been discussed here in > the the past, such as myMatch5, etc. This is great when the sample > name match exactly, however I am attempting to deal with sample names > that do not match exactly. They will differ only in the length of > name; one list may contain for example a sample name of 3_78457_5 and > the second may only have 3_78457 or 78457_5. > It should be possible to search the 2 data lists for columns that have > the largest run of consecutively matching characters, and assume that > is the correct match. Would it be possible to develop a similarity > criteria? I can see that this type of function would very useful in > things more important that this. > Any suggestions greatly appreciated. > Charles Koehler -- Charles, You could use a function similar to this one : In[1]:= similar[alpha_String, beta_String]:= Module[{}, charalpha = Characters[alpha]; charbeta = Characters[beta]; leng = Max[Length[charalpha],Length[charbeta]]; padalpha = PadRight[charalpha,leng]; padbeta = PadRight[charbeta,leng]; robeta = RotateLeft[padbeta,#]& /@ (Range[leng]-1); transbeta = Transpose[{padalpha,#}]& /@ robeta; countalpha = Count[#,First[#] == Last[#]&]& /@ transbeta; roalpha = RotateLeft[padalpha,#]& /@ (Range[leng]-1); transalpha = Transpose[{padbeta,#}]& /@ roalpha; countbeta = Count[#,{x_,x_}]& /@ transalpha; 100.(Max[countalpha]+Max[countbeta])/leng ]; similar[3_78457_5,3_78457] Out[2]=77.7778 In[3]:=similar[3_78457_5,78457_5] Out[3]=77.7778 In[4]:=similar[3_78457_5,3_78457_5] Out[4]=100. In[5]:=similar[3_78457_5,666] Out[5]=0 hth --- va -- 0% de pub! Que du bonheur et des vrais adh.8erents ! Vous aussi inscrivez-vous sans plus tarder!! Message post.8e .88 partir de http://www.gyptis.org, BBS actif depuis 1995. === Subject: Re: 3D plots from lists Here is a simple example where a text file of triplets of numbers are created. These are read back in, an Interpolation of them is created, and then we can plot the Interpolation function as a surface. Is this what you had in mind? testdata = Flatten[Table[{x, y, Sin[x y]}, {x, 0, 6, .3}, {y, 0, 6, .3}], 1]; Export[ junk.txt, testdata, Table]; stream = OpenRead[junk.txt]; data = ReadList[stream, {Number, Number, Number}]; Clear[f]; f = Interpolation[data]; ParametricPlot3D[{x, y, f[x, y]}, {x, Min[data[[All, 1]]], Max[data[[All, 1]]]}, {y, Min[data[[All, 2]]], Max[data[[All, 2]]]}] P.S. If your Fortran created data set uses E format, you may need to do a fancier read of the data, using StringToStream and Read, rather than the simpler ReadList. christopherpurcell@mac.com > This might be naive, but I worked on this problem for days, and the > users manual seems to be of no help. > I have a 3 column output generated by a FORTRAN program, in the > following form: > X Y F(X,Y) > Is there any way to make Mathematica understand this format and plot > it with something like ListPlot3D? It seems to require all 3D plots > to be square arrays of the form F(X,Y) only, and I would much rather > not modify the fortran program output. > GT === Subject: Re: 3D plots from lists look what TriangularSurface3Plot[] from DiscreteMath`ComputationalGeometry` can do for you. > This might be naive, but I worked on this problem for days, and the > users manual seems to be of no help. > I have a 3 column output generated by a FORTRAN program, in the > following form: > X Y F(X,Y) > Is there any way to make Mathematica understand this format and plot > it with something like ListPlot3D? It seems to require all 3D plots > to be square arrays of the form F(X,Y) only, and I would much rather > not modify the fortran program output. > GT === Subject: Re: 3D plots from lists > This might be naive, but I worked on this problem for days, and the > users manual seems to be of no help. > I have a 3 column output generated by a FORTRAN program, in the > following form: > X Y F(X,Y) > Is there any way to make Mathematica understand this format and plot > it with something like ListPlot3D? It seems to require all 3D plots > to be square arrays of the form F(X,Y) only, and I would much rather > not modify the fortran program output. > GT Presumably what you are looking for is the function ListSurfacePlot3D of the Graphics`Graphics3D` Standard Package. Andrzej Kozlowski Chiba, Japan http://www.mimuw.edu.pl/~akoz/ === Subject: Re: freeing memory for animated graphics for more swap space. > Hi you, > I would like to show an animation of a long list of graphics, > unfortunately after a evaluating a few graphics mathematica stops > request freeing memory. Is it possible to assign using more memory to > mathematica?