Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

let us assume we have some data in the following form.

Table[data[[1,i,{1,2}]],{i,1,Length[data[[1]]]}]

This would give all $x-y$ pairs of the first file. What I want to do now is to multipliy this table with constant factors but different factors for $x$ and $y$. I found a solution for this with

MapThread[ Composition[Flatten, List], {xlist, #}] & /@ ylist

where xlist is

 Table[data[[1,i,1]],{i,1,Length[data[[1]]]}]*c1

and ylist is

 {Flatten[Table[data[[1,i,2]],{i,1,Length[data[[1]]]}]]}*c2

Is there a more comfortable way to do this?

Thank you in adavance

Sincerely


EDIT:

 test= {{0.0015856, -1486.76}, {0.00157776, -1483.45}}

I need :

 test2= {{1.5856, -148.676}, {1.57776, -148.345}}

So the $x$ values should be multiplied with $1000$ and the $y$ values multiplied with $0.1$

EDIT2:

Transpose is exactly what I need, thank you very much

share|improve this question

marked as duplicate by Kuba, rasher, m_goldberg, bobthechemist, Jens May 22 at 17:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Please state clearly what is the structure of the list you want to multiply by those constants- Is it {{x1,y1},{x2,y2}..}? –  belisarius May 22 at 2:27
    
Your question is quite opaque. Is something like this what you mean? pairs = {{1, 2}, {3, 4}, {5, 6}}; Transpose[{10, 100}*Transpose[pairs]] –  rasher May 22 at 2:35
    
Closely related topics: flexible threading and elegant operations on columns. Moreover: test[[ ;; , 1]] *= 1000; test[[ ;; , 2]] *= .1; –  Kuba May 22 at 8:37

1 Answer 1

Try this:

    test = {{0.0015856, -1486.76}, {0.00157776, -1483.45}};
Map[{1000*#[[1]], 0.1*#[[2]]} &, test]

(*   {{1.5856, -148.676}, {1.57776, -148.345}}   *)
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.