Help with error using vpasolve!

Im trying to graph Euler curves of Material Resistances using the secant formula.
Curves that should look like this:
But instead I have some (I believe in my inocence and inexperience) "errors" on some points of my formula that make the graph look like this:
So the first part is actually correct, but clearly those spikes are not, and Im having a hard time pinpointing the error, the code is really basic:
"La" being the horizontal axis, and "X" the vertical one/ "e" are each different curve which is excentricity./"Tcr" is maximum tension
for j=1:length(e)
for i=1:length(La)
S=0;
Tcr=(pi()^2*190000)/(La(i)^2);
syms x;
S=vpasolve(x*(1+e(j)*sec((La(i)/2)*sqrt(x/190000)))==Tcr,x);
R(i)=S;
end
plot(La,R,'-')
end
I believe so much so, is not an error in the mathematics, but probably the coding or the functions used that spiral in the error.
HELP! please! Thanks for your suggestions!

1 Comment

What are some sample e and La values that it fails on ?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 24 Mar 2019
Edited: Walter Roberson on 24 Mar 2019
Testing with a few values, it looks to me as if the equation has an infinite number of solutions (with the catch basins getting narrower and narrower with increasing La).
I suggest that each iteration, you use the previous solution as the initial guess for the vpasolve(). That should help but might not cure the problem completely.

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Asked:

on 24 Mar 2019

Edited:

on 24 Mar 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!