LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3d surface not plotting correctly

Solved!
Go to solution

Just curious why this isn't making the "saddle" shape like it should. Just playing around and expanding my knowledge so this isn't exactly in need of a "high priority" response. I'm going for the equation y = x^4-z^4.

 

Also, while I'm at it, why does the Z array take 2-d data. It makes sense...but at the same time it doesn't make sense (at least in my head haha).

 

Message Edited by for(imstuck) on 06-08-2010 12:02 PM
0 Kudos
Message 1 of 9
(3,538 Views)
Now that I look at it, I think part of my problem is that the equation is in the y= format rather than z=. Hence, I keep overwriting my arrays in the for loop. However, I will leave this posted and I'm sure someone will point me in the right direction.
0 Kudos
Message 2 of 9
(3,533 Views)
Solution
Accepted by topic author GregFreeman

You almost have it right.  In order to have the correct Z array, you need to change the data of x and y independently.  This snippet should give you the proper graph.

 

3d surface(update).png

National Instruments
Applications Engineer
Message 3 of 9
(3,504 Views)

Scott W wrote:

You almost have it right.  In order to have the correct Z array, you need to change the data of x and y independently.  This snippet should give you the proper graph.

 

 


Could you explain in a little more detail why this is? For some reason I'm having trouble wrapping my head around it.

I think I am thinking too much "equation" and not enough "array's it's producing"
Message Edited by for(imstuck) on 06-09-2010 01:43 PM
0 Kudos
Message 4 of 9
(3,495 Views)

Nevermind, I think I got it. You need to say ok, when y is -5 and x is -5,-4,-3... what is z for each of those values. Then store it in an array. Then when y is -4 and x is -5,-4,-3... what are the z values etc, etc

 

Anyways, thanks for the solution!

0 Kudos
Message 5 of 9
(3,483 Views)
That's exactly correct.  If you want to think of it in equation format, this is actually z = x^4 - y^4.  The way you had it set up is more like a ramp function of z, but the points of y were in the function of x^4 - y^4 and the points of x where from -5 to 5.  There was no thrid dimension, as you mentioned earlier, because you were over writting the y component each time.  If you don't transpose the 2D array, you can see the two dimensional graph.
National Instruments
Applications Engineer
0 Kudos
Message 6 of 9
(3,464 Views)

Let's keep with the theme of plotting 3D graphs incorrectly. Simple sphere using cartesian coordinates. Don't know what to do about the imaginary numbers. Apparently 2 years after getting a Purdue Engineering degree, I can't do Engineering anymore. Or my brain just is having trouble thinking this way. Or...I like to make excuses.

 

I found an example with active x plots, but I am trying to stick with this newer surface plot.

 

Feel free to use spherical coordinates if you want.

0 Kudos
Message 7 of 9
(3,438 Views)
Ooops, attachment.
0 Kudos
Message 8 of 9
(3,428 Views)

Hey!

 

I've been working on this on and off throughout the day and haven't quite figured it out but was able to figure a few things out.

 

To work with imaginary numbers LabVIEW has a complex data type. You can change all of your data types to be this by right clicking on your data and selecting Representation»Complex Double. This will allow you to make calculations using imaginary numbers.

 

As for plotting the sphere correctly, I haven't been able to completely figure it out but I did do the following and it got me a bit closer.

Instead of starting from -4 to create the axis range, I started from -5 and changed the number of iterations to 11. This gave me a choppy graph so I increase the number of iterations (101) and changed the axis step size from 1 to .1089. This gave me a sphere with a plane in the middle. I didn't quite figure out how to get rid of the plane, but thought I would share what I've done when troubleshooting this issue.  

 

I'll try working on it again on Monday if I have time. I hope you enjoy your weekend!

Stephanie A.
Americas Marketing Manager
National Instruments
0 Kudos
Message 9 of 9
(3,401 Views)