cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Create a 3-D plot of a function with two variable

fahmed-2
13-Aquamarine

Create a 3-D plot of a function with two variable

Hello All,

 

I am trying to generate a 3-D plot for a function. I am having the following issue.

 

fahmed2_0-1689189946109.png

 

Please help.

 

 

ACCEPTED SOLUTION

Accepted Solutions
ttokoro
20-Turquoise
(To:fahmed-2)

Requires long time to make plot.

 

image.pngimage.png

View solution in original post

24 REPLIES 24
ttokoro
20-Turquoise
(To:fahmed-2)

Requires long time to make plot.

 

image.pngimage.png

fahmed-2
13-Aquamarine
(To:ttokoro)

Thank you @ttokoro . What is purpose of using third brackets " [  ]". Is this for assigning the matrix values in each corresponding cells inside the "Ans"

ttokoro
20-Turquoise
(To:fahmed-2)

Your sheet shows error mesage for x and y data must have no unit. So I make Ans as [x y z-value with unit]. 

And stack all S and Df  and  its Ans.

I try to use [NaN NaN NaN] to stack. In this plot, z axis also has no unit.

 

 

image.pngimage.png

fahmed-2
13-Aquamarine
(To:ttokoro)

@ttokoro thank you. why was "not a number (NaN)" required for stacking...should not it be stacked by itself without using NaN. Please help

ttokoro
20-Turquoise
(To:fahmed-2)

Instead of point data, [NaN NaN NaN] turn off to connect each 3D point [x y z] data by stacking.

Werner_E
25-Diamond I
(To:fahmed-2)

In fact, the error message reveals the cause and also gives the hint to the solution of the problem:
The variables for the independent variables (x, y) must (unfortunately) be unitless. Only the dependent variable (z), i.e. the function result, may have a unit.

So omit the unit meter at the range variables and add them when calling the function.

Werner_E_0-1689212173357.png

 

The plot takes "endless" to finish because the function seems to be defined quite inefficient.

You sure should consider to implement the improvement I suggested in another thread of yours which at least speeds up the calculation for the factor 5.

Personally I would prefer using CreateMesh() instead of range variables

 

fahmed-2
13-Aquamarine
(To:Werner_E)

Thank you @Werner_E . Is it possible to make the plot as individual dots 

Werner_E
25-Diamond I
(To:fahmed-2)


@fahmed-2 wrote:

Thank you @Werner_E . Is it possible to make the plot as individual dots 


Sure! Simply format the plot that way

Werner_E_0-1689214590189.png

Werner_E_1-1689214627130.png

I used the data  structure created with CreateMeashj() but you can do the same with the plot using the range variables.

 

fahmed-2
13-Aquamarine
(To:Werner_E)

Also, I am having the following image using your process @Werner_E . The box was marked "red". Please help

 

fahmed2_0-1689214045205.png

 

Werner_E
25-Diamond I
(To:fahmed-2)

And the error message is?

As far as I see your comp is still computing......

 

Personally I would prefer using the CreateMesh() function anyway

Werner_E_0-1689214388227.png

 

File (Prime9) with a speedier function attached

 

 

fahmed-2
13-Aquamarine
(To:Werner_E)

Wish I I had 9 but unfortunately, mine is 7

Werner_E
25-Diamond I
(To:fahmed-2)

I guess it should work as well in P7. P9 is not really a huge step forward (sure not worth any money).

It takes very long to calculate, even if you apply the speed up modification I explained in the other thread of yours.

 

Here is the speed-up again as used in the current sheet of yours:

Werner_E_0-1689215103975.png

Mind the vectorization!

 

 

fahmed-2
13-Aquamarine
(To:Werner_E)

how do I get "CreateMesh" function

Werner_E
25-Diamond I
(To:fahmed-2)


@fahmed-2 wrote:

how do I get "CreateMesh" function


Its a standard function in Prime. Its sure available in your Prime7 as well.

I guess it was even implemented in the very first Prime version 😉 The 3D plot has not improved since then.

But maybe @LucMeekes  is able and willing to convert my attached sheet for you in Prime 7 format - he has found a way to do so and is able to do.

 

 

fahmed-2
13-Aquamarine
(To:Werner_E)

Thank you @Werner_E and @ttokoro . It works great. I was wondering how to extract values from the Mesh function. For example, here, if I need all the values of Q for different values of B_f at a constant S or, get all values of Q for different values of S at a constant B_f. Please help.

fahmed2_0-1689359021224.png

 

 

Werner_E
25-Diamond I
(To:fahmed-2)

Q is a nested vector containing matrices for the x, y and z values of the points to be plotted.

If you need the value for a specific S and B.f value, simply use the original function to get it, not Q.

Werner_E_0-1689361438237.png

 

And if your goal is to highlight some specific positions in the 3D plot, you could do it as shown here

Werner_E_1-1689361492251.png

 

Actually I don't understand why you refuse to speed up your function calculation as already shown.

LucMeekes
23-Emerald III
(To:Werner_E)

Here is.

 

Success!
Luc

fahmed-2
13-Aquamarine
(To:LucMeekes)

Thank you @LucMeekes 

ttokoro
20-Turquoise
(To:fahmed-2)

image.pngimage.pngimage.png

fahmed-2
13-Aquamarine
(To:ttokoro)

Thank you @ttokoro.  Looks amazing!! 

Werner_E
25-Diamond I
(To:ttokoro)

Can alternatively be achieved using CreateSpace()

Werner_E_2-1689460221374.png

May be formatted with lines and/or points. Unfortunately Prime provides only one size which is equally valid for points and lines. Workaround would be to use two plot traces 😞

 

fahmed-2
13-Aquamarine
(To:Werner_E)

Thank you @Werner_E . This is awesome!! Please advise as why did you put numbers 40 and 60 for defining A and B, respectively.

Werner_E
25-Diamond I
(To:fahmed-2)


@fahmed-2 wrote:

Thank you @Werner_E . This is awesome!! Please advise as why did you put numbers 40 and 60 for defining A and B, respectively.


Just to get a finer resolution. Default value would be 20 if you omit this parameter (see the help info for CrreateSpace()  and also for CreateMesh() ).

Werner_E_0-1689791676138.png

As you can see in the picture I also used a finer grid for the surface, too, to et a bit more details. It takes longer to calculate, but as I implemented the already mentioned speedier function we can wait for it to finish.

fahmed-2
13-Aquamarine
(To:Werner_E)

Salute!!

Announcements

Top Tags