New answers tagged

0

Piecewise basically uses an array, so you can put it with a Table. for example val = Sort@RandomReal[1, 10] step[x_] = Piecewise[Table[{i, val[[i - 1]] < x < val[[i]]}, {i, 2, 10}]]; Plot[step[x], {x, 0, 1}, GridLines -> {val, {}}] {0.254837, 0.27277, 0.302014, 0.339608, 0.504063, 0.567221, 0.826478, \ 0.869325, 0.879442, 0.904477}


7

Rule-replacement with x^n_. :> Derivative[n,0][a][y,z] (as done in Kuba's answer) has two drawbacks: if your polynomial has a constant term, then it will not be replaced by the zero-th derivative a[y,z], and if your polynomial is not expanded the result is incorrect. Namely, (1+x)(2+x) becomes (1+a'[y,z])(2+a'[y,z]) rather than 2a[y,z]+3a'[y,z]+a''[y,z] (...


4

{x, x^2, x^2 + x} /. x^n_. :> Derivative[n, 0][a][y, z]


5

Applying Fourier to a multi-dimensional array does a multi-dimensional FFT, so your first case generates the 2D FFT of all the trajectories. In your case you want to map the 1D FFT over each trajectory. ampFFT = Abs[Fourier[#,FourierParameters->{-1,1}]&/@(Transpose@x); Now each element of ampFFT is the 1D FFT of one trajectory, i.e. ampFFT[[i]] == ...



Top 50 recent answers are included