       RE: plotting multidimensional arrays

• To: mathgroup at smc.vnet.net
• Subject: [mg69587] RE: [mg69547] plotting multidimensional arrays
• From: "David Annetts" <davidannetts at aapt.net.au>
• Date: Sat, 16 Sep 2006 03:50:31 -0400 (EDT)

```Hi Mickey,

> I have a list of numbers,
> cc(1,2)=20
> cc(1,3)=45
>
> and so on. I would like to plot it as a 3 dimensional plot,
> with the index as x and y and the value as the z value but I
> am having trouble doing that. Here is what I was trying. I
> create the array first,
>
> cc=Table[0,{i,500},{j,500}];

You are creating an 500 x 500 array filled with zeros.

> This works fine. Then I assign the values for the elements.
>
> cc[][]=20;

This will return the 2nd element in the first row.  You mean cc[[1, 2]] =
20;

> But here I get an error.

Yes.  Look at Part[] in the online help.

> What am I doing wrong?

At the very least, assuming that you can write C(++) like code and expect it
to work ....

You say you have a list of numbers.  Where?  On paper?  In a file on your
disc?  Assuming it's the latter, we can read them directly into Mathematica.

idat  = Import["c:/Tmpfiles/Surface.dat", "CSV"];
idat = ToExpression[#] & /@ idat;

And plot them as a surface (after loading the proper package)

Needs["Graphics`"]
ListSurfacePlot3D[idat];

Or as discrete points ...

rdat = Partition[Flatten@idat, 3];
ScatterPlot3D[rdat];

It depends on how you read your data from the file on disc, and what exactly
you want to do with them.

How about looking at the help for Import[] as well as ListPlot3D &
ListSurfacePlot3D.  Try the examples.  Look at the start of the sample data
to see the required format for the data.

Regards,

Dave.

```

• Prev by Date: question about plot
• Next by Date: Re: Known recursion link to Hermite polynomials not solved in Mathematica
• Previous by thread: Re: plotting multidimensional arrays
• Next by thread: Re: plotting multidimensional arrays