Path: news.mathworks.com!not-for-mail From: "Yehonatan " <math8yehonatan@gmail.com> Newsgroups: comp.soft-sys.matlab Subject: Re: Gaussian 3D plot Date: Sat, 13 Apr 2013 16:06:07 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 67 Message-ID: <kkbvpf$lq5$1@newscl01ah.mathworks.com> References: <kk9rf8$pnj$1@newscl01ah.mathworks.com> Reply-To: "Yehonatan " <math8yehonatan@gmail.com> NNTP-Posting-Host: www-00-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1365869167 22341 172.30.248.45 (13 Apr 2013 16:06:07 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sat, 13 Apr 2013 16:06:07 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 4226123 Xref: news.mathworks.com comp.soft-sys.matlab:793457 Another thing, To be clearer. In the last post i showed you this: x = [1,2,3,4,5]; y = [1,2,3,4,5]; z = [1,2,3,4,5]; Here, the data points are: 1) x = 1,y = 1,z = 1; 2) x = 2,y = 2,z = 2; 3) x = 3,y = 3,z = 3; 4) x = 4,y = 4,z = 4; 5) x = 5,y = 5,z = 5; And the result surface was this: Surface = 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 What you see here is the z axis value. The location for each value is determined by The correspond x and y value for that z value. If you give me your data points i can plot them or if you want to learn how i can explain to you in more detail. However, keep in mind that if you will not give sufficient data point the result surface may be not complete as shown by the zero value of the surface i showed you. If for example i want to plot the function x^2 in 3d. I want that there will be 5 grid points on the x axis and 5 grid points on the y axis. That means i want to calculate the function for every possible x and y grid points. That means i need to calculate the function for 25 possible x and y grid points. In order for me to calculate the function for every possible grid point i use meshgrid like this: [X,Y] = meshgrid(1:5,1:5); Here i told meshgrid to create tow matrices that will contain all of the possibilities. Here is how they look: X = 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 Y = 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 Now, if i look at each correspond cell of the tow matrices like: cell (1,1) and cell(5,5) they give me a grid possibility. Now i need to calculate z for each correspond cell of the tow matrices like this: Z = X.*Y; Z = 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25 The calculation did this: Z(1,1) = 1*1 and this Z(5,5) = 5*5 and more. Now i have a z value for each x and y grid point value. These points i will give matlab to plot. However, not all functions can be generated like that. If you have a problem doing that just gives me the points you have and i will plot them. Keep in mind you give me points that have x,y and z axis values..