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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Plot for function is not working

FC_10037391
8-Gravel

Plot for function is not working

I want to frame a function to plot for Shear force 

1 ACCEPTED SOLUTION

Accepted Solutions

Actually Luc already pointed out your main error - your function does not provide a value for x=L/2.

You have to decide which value S(L/2) should return. Because it was easier to do I simply replaced your "if else" for a simple "else".

Werner_E_0-1661456777519.png

As you can see it was not really necessary to delete the equal sign after the range definition which turns the range into a vector. This is because you used vectorization at S(x) and so you are plotting one vector of values over another.
But I consider it important that you know exactly what that little equal sign actually accomplishes. And you also should be aware, that this conversion of a range into a vector is an undocumented and thereby not supported feature.

 

Usually when you plot a function you would simply use a normal range for the abscissa values and the function (vectorization is not necessary) at the ordinate.

Werner_E_1-1661457116224.png

As you can see I also changed the second value in the range to decrease the step size and so get a "more vertical" line at the centre without noticeable slope.
BTW, the plot done that way would also work using your original function S(x). This function would still throw an error for x=L/2, but the rest would plot:

Werner_E_0-1661457501974.png

But of course in any case you should redefine S(x) in a way to return a value for any input value.

View solution in original post

2 REPLIES 2
LucMeekes
23-Emerald III
(To:FC_10037391)

Your little program

LucMeekes_0-1661449613718.png

does not provide for the situation where x=L/2. That's what the error message points to.

You have to choose where L/2 should belong to, either A or A-B, or yet another value, then change the program accordingly.

Suppose it belongs to A-B, then you can just:

LucMeekes_3-1661450129095.png

 

Next thing: You should delete the evaluation (=) in:

LucMeekes_1-1661449931173.png

because it changes the range x into a vector. So just:

LucMeekes_2-1661450030213.png

Then you can change the 9 to 40 and see the plot over the entire range to L.

 

Success!
Luc

Actually Luc already pointed out your main error - your function does not provide a value for x=L/2.

You have to decide which value S(L/2) should return. Because it was easier to do I simply replaced your "if else" for a simple "else".

Werner_E_0-1661456777519.png

As you can see it was not really necessary to delete the equal sign after the range definition which turns the range into a vector. This is because you used vectorization at S(x) and so you are plotting one vector of values over another.
But I consider it important that you know exactly what that little equal sign actually accomplishes. And you also should be aware, that this conversion of a range into a vector is an undocumented and thereby not supported feature.

 

Usually when you plot a function you would simply use a normal range for the abscissa values and the function (vectorization is not necessary) at the ordinate.

Werner_E_1-1661457116224.png

As you can see I also changed the second value in the range to decrease the step size and so get a "more vertical" line at the centre without noticeable slope.
BTW, the plot done that way would also work using your original function S(x). This function would still throw an error for x=L/2, but the rest would plot:

Werner_E_0-1661457501974.png

But of course in any case you should redefine S(x) in a way to return a value for any input value.

Top Tags