# Tag Info

1

Transpose[#[[1]]] + #[[2]] &[PadRight[{s, t}, {2, -5, 5}]]

2

t = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}} tm = Prepend[t, {}]; a = PadRight[#, 5] & /@ tm a + 10 Transpose[a] // MatrixForm UPDATE Exploiting the much better and more concise advice in comment by ybeltukov: b = ArrayPad[PadRight@t, {{1, 0}, {0, 1}}] b + 10 Transpose[b] // MatrixForm

2

Very verbose but I was trying to find a different way :) Reverse[Flatten@ Pick[m, Normal@ SparseArray[{{i_, j_} /; Abs[j + i] == # -> 1}, {4, 4}], 1] & /@ Range[2, 5], 2]

2

We want to extract the index of the upper left triangular position using the positions: {1,1} {2,1} {1,2} {3,1} {2,2} {1,3} ⋮ The following function using Table uses the algorithm so that the row increments and then decrements as the column increments (not sure the words make sense but look at the algorithm below). lut1[m_] := Table[ Table[ m[[j - ...

3

upperOffTriag[m_] := With[ {i = Table[Table[{n, k + 1 - n}, {n, k, 1, -1}], {k, 1, First@Dimensions[m]}]}, Map[Part[m, Sequence @@ #] &, i, {2}] ] upperOffTriag[m] {{1}, {5, 2}, {9, 6, 3}, {13, 10, 7, 4}}

6

m = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}; MapThread[m[[##]] &, {Reverse@Range@#, Range@#}] & /@ Range@Length@m {{1}, {5, 2}, {9, 6, 3}, {13, 10, 7, 4}}

6

Just to show a less elegant way :) f[m_] := Apply[m[[##]] &, Table[{i - j + 1, j}, {i, Length@m}, {j, i}], {2}] f@m (*{{1}, {5, 2}, {9, 6, 3}, {13, 10, 7, 4}}*)

5

Here's a different version, much more verbose. m = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}; DeleteCases[#, 0]&@*Reverse /@ Transpose @ UpperTriangularize @ MapThread[RotateRight[#1, #2] &, {m, Range[0, Length@m - 1]}] Here's another one, slightly less verbose: MapIndexed[Reverse@#1[[;; First@#2]] &, ...

5

Two functions to consider: Diagonal and Reverse Your data: m = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}} Solution Reverse@Table[ Reverse@Diagonal[Reverse /@ m, k], {k, 0, Length[m] - 1}] {{1}, {5, 2}, {9, 6, 3}, {13, 10, 7, 4}} Function: lut[m_] := Reverse@Table[ Reverse@Diagonal[Reverse /@ m, k], {k, 0, Length[m] - ...

1

Adapting @Silvia´s code (errr ... mostly copying it) data = Uncompress@Import["http://pastebin.com/raw.php?i=hkhuyvza"]; data1 = Rest@Transpose[Rescale /@ (Transpose@data)]; peakfunc[A_, μ_, σ_, x_] = A^2 E^(-((x - μ)^2/(2 σ^2))); Clear[model, modelvalue] model[data_, n_] := Module[{dataconfig, modelfunc, objfunc, fitvar, fitres}, dataconfig = {A[#], ...

6

Your provided data is very noisy. You can get more information from it if you filter it first. I will apply a LowpassFilter and a logarithmic transform on the $y$ values, and scale down the $x$ values. This usually helps the fitting algorithm. datat = Transpose[{#[[All, 1]]/1500, Log10[LowpassFilter[#[[All, 2]], .1]]} &@data]; ListPlot[datat, ...

4

I would like to point out that Listable in a pure Function effectively unpacks the array, and makes it much slower than Map for pure Functions. Downvalues always unpack so SetAttributes[f, Listable] doesn't affect performance there. The bottom line is that if one wants to use user defined listability it must be inside a compiled function, otherwise use Map ...

Top 50 recent answers are included