0
$\begingroup$

I have two vectors (plain lists), say a,b, from which I generated a 2d table, say mat. It's not a direct expression like mat[[i,j]] = a[[i]] + b[[j]], rather some more complicated computation that spans much of my code, but each entry $ij$ is essentially just some function of the corresponding a[[i]] and b[[j]]].

I'd like to plot that, perhaps as a contour plot, but I see that Mathematica expects the data to be given as a matrix where each entry $ij$ is a triplet a1[[i]],a2[[j]],mat[[i,j]].

How do I construct this matrix of triplets in a proper Mathematica "way of thinking"? (i.e. without nested loops etc.) Or alternatively, can I use my current data structure and plot it directly?

$\endgroup$
  • $\begingroup$ See ListContourPlot, it doesn't make any difference how you generated your mat $\endgroup$ – Bob Hanlon Aug 7 at 14:07
1
$\begingroup$

Try

Table[{a[[i]],b[[j]],a[[i]]+b[[j]]},{i,1,ni},{j,1,nj}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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