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$
1
  • $\begingroup$ See ListContourPlot, it doesn't make any difference how you generated your mat $\endgroup$ Commented Aug 7, 2019 at 14:07

1 Answer 1

1
$\begingroup$

Try

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.