Re: plotting multidimensional arrays
- To: mathgroup at smc.vnet.net
- Subject: [mg69605] Re: plotting multidimensional arrays
- From: mickey <micky at hotmail.com>
- Date: Sun, 17 Sep 2006 06:57:34 -0400 (EDT)
- Organization: Ohio State University
- References: <eegb31$js$1@smc.vnet.net>
David Annetts wrote:
> 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[[1]][[2]]=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.
>
Thanks to everyone who responded. It works fine now.
-M