I have a 3D array of the form:
{{{a1,a2,a3},{b1,b2,b3}...}}}
and ListPlot3D
only accepts data of form:
{{a1,a2,a3},{b1,b2,b3}...}.
Is there any way I can convert from one to the other?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI have a 3D array of the form:
{{{a1,a2,a3},{b1,b2,b3}...}}}
and ListPlot3D
only accepts data of form:
{{a1,a2,a3},{b1,b2,b3}...}.
Is there any way I can convert from one to the other?
Assuming your initial list looks like this:
lis = {{{1, 2, 3}, {2, 3, 4}}}
You can remove the outer list with Flatten:
Flatten[lis,1]
Results in:
{{1, 2, 3}, {2, 3, 4}}
OR
You could replace the outer containing list with the actual function using apply:
ListPlot3D @@ {{{1, 2, 3}, {2, 3, 4}}}
Which is equivalent to,
Apply[ListPlot3D , {{{1, 2, 3}, {2, 3, 4}}}]
{{{a1,a2,a3},{b1,b2,b3}...}}}[[1]]
.
$\endgroup$
– David G. Stork
Oct 2 '15 at 23:51
Flatten
$\endgroup$ – Sektor Oct 2 '15 at 21:07