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
Prime 7
I am trying to calculate volume of a cone as a function, in steps of 0.3 meters.
I'm not sure what I'm doing wrong.
can someone enlighten me?
thanks in advance
Solved! Go to Solution.
From what I had seen in the sheet I assumed that only cones with a ratio of r : h = 2.5 : 6 should be considered with h running up to 6m.
If you should be able to choose r and h independently of each other, then I would rather define a function in both variables.
The picture shows how to get the values seen in Stuarts screen shot. r is the vector you already defined and while vectorizing is not mandatory here, I still think it's a good habit to do so.
You were running into Primes infamous autolabelling feature.
Look closely at t"he "h" on the RHS of the definiton of f(h). You'll notice its coloured green like the symbol pi. That means its labelled as being a constant.
There is a predefined constant h built into Prime:
and thats the reason for the strange result you see.
Manually label that h as being a variable
AND
delete the "f(h):=" because you obviously don't want to define a function
AND
vectorize the expression
and you should see what you expect.
If you want to define a function and also want to explicitly use a variable r in your formula, you could do it that way:
Again you have to vectorize the function call!
Note that you defined h as a range but you turned it into a vector (by using the undocumented trick to immediately evaluate after the definition).
Thats the reason you have to use vectorization also when you plot the function (left plot; plotting one vector over the other)
If you define a range (like hh in the plot to the right), you don't need to vectorize
@KarstenJ wrote:
Prime 7
I am trying to calculate volume of a cone as a function, in steps of 0.3 meters.
I'm not sure what I'm doing wrong.
can someone enlighten me?
And here's an additional, slightly different version to Werner's.
Stuart
From what I had seen in the sheet I assumed that only cones with a ratio of r : h = 2.5 : 6 should be considered with h running up to 6m.
If you should be able to choose r and h independently of each other, then I would rather define a function in both variables.
The picture shows how to get the values seen in Stuarts screen shot. r is the vector you already defined and while vectorizing is not mandatory here, I still think it's a good habit to do so.