MATLAB: Solving a function using symbolic

symbolic

This is a mode shape problem for a cantilever beam.
clear;clc;
Mt = 0.008;
It = 1666.67e-12;
m = 0.002700;
L = 0.1;
E = 70e9;
I = 0.8333;
a = Mt/(m*L);
b = It/(m*L^3);
c = Mt*It/(m^2*L^4);
syms d e;
subs(d,0);subs(e,1);
syms x;
f = 1+cos(x)*cosh(x)+x*(a)*(cos(x)*sinh(x)-sin(x)*sinh(x))-x^3*(b)*(cosh(x)*sin(x)+sinh(x)*cos(x))+x^4*(c)*(1-cos(x)*cosh(x));
y1=feval(symengine, 'numeric::fsolve',f,'x=d..e');
This is my Matlab code, I am only able to solve the expression if I give a range of 0 to 1 directly in the last line. Shown below…
y1=feval(symengine, 'numeric::fsolve',f,'x=0..1');
My queries are:
1. Is there any way to obtain all (say 10) the solutions for the above expression?
So far I tried by expanding the range, say 0 to 10. Such a long range gives the largest solution of the equation, so I had to minimize the range.
2. Is there any way to put the range in a loop, so that I can get all the numerical solutions for the problem.
Thanking you,
Vittal.

Best Answer

Remove
subs(d,0);subs(e,1);
Use
d = 0; e = 1;
y1=feval(symengine, 'numeric::fsolve', f, subs('x=d..e') );
e.g.,
for d = 0 : 9
e = d + 1;
y1=feval(symengine, 'numeric::fsolve', f, subs('x=d..e') );
if ~isempty(y1)
fprintf('Solution found at %f\n', y1);
end
end