# Operation with lists

I have created this code and was wondering if you could suggest a less convoluted way of solving the problem. I have two lists:

unitvector={{0.662689, 0.748895}, {0.715053, 0.69907}, {0.763178,
0.646188}, {0.821767, 0.569823}, {0.85637, 0.516362}, {0.891767,
0.452495}, {0.926008, 0.377505}, {0.93515, 0.354251}, {0.930926,
0.365209}, {0.947215, 0.320599}, {0.943255, 0.33207}, {0.866993,
0.49832}, {0.497458, 0.867488}, {0.396184, 0.918171}, {0.374449,
0.927248}, {0.118057, 0.993007}, {0.0974299, 0.995242}, {0.0334211,
0.999441}};

incl={{0.26706}, {0.247503}, {0.232131}, {0.215581}, {0.193663},
{0.185976}, {0.161986}, {0.155111}, {0.136908}, {0.118314},
{0.106016}, {0.100337}, {0.100511}, {0.108912}, {0.115234},
{0.151056}, {0.183037}, {0.200112}};


I want to multiply every element in unitvector by the relative value in inlc, which is timed each time by an incremental number from 0 to 20. My code is as follows:

a = Flatten[
Transpose[Table[unitvector[[1 ;;, 1]]*(i*incl), {i, 0, ndiv}]]];
b = Flatten[
Transpose[Table[unitvector[[1 ;;, 2]]*(i*incl), {i, 0, ndiv}]]];
points = Partition[Partition[Riffle[a, b], 2], Length[unitvector]];


Then plotting the results should look like this:

A fair bit simpler than what you are doing:

ndiv = 20;

foo = unitvector * Flatten[incl];
bar = Table[i*foo, {i, 0, ndiv}] ~Flatten~ {2, 1};
points2 = Partition[bar, Length @ foo];

points == points2   (* True *)

• "A fair bit simpler than what you are doing", with "laddie" tacked on, read in the voice of Scotty... +1
– ciao
Commented Jun 16, 2016 at 11:29
• @ciao LOL I can hear that now :-) Commented Jun 16, 2016 at 11:30
• @ciao. Surely Scotty would say "A muckle simpler than what ye be doing, Cap'n" Commented Jun 16, 2016 at 12:57
data = Table[
Table[
unitvector[[i]] Flatten[incl][[i]] j, {i, 1, Length[incl]}], {j, 0, 20}];
ListPlot[data]


Or, if you want, Transpose the data, for data=Transpose[data]

• @Kuba Indeed, edited. Commented Jun 16, 2016 at 12:13