cannot solve for unknown variable; stuck in setting search range in the command vpasolve
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Md Shariful Islam
el 23 de Jul. de 2022
Comentada: Md Shariful Islam
el 25 de Jul. de 2022
Referring to this answer, Walter helped me solving the problem. In that answer, there was a search range specified (vpasolve(sigma, [0 .5e-4])).
Now, my question is, how can I define the search range? I tried to manipulate that range but failed to get the required range. I want to know how can I set that range for any problem.
I am adding one code for reference.
clc; clear; close all;
%Constants and variable
L= 300e-6;
O= 5e-6;
T_init= [25 198.6111 372.2222 545.8333 719.4444 893.0556];
D_T = 0:25:500;
T_set= D_T+T_init(1);
theta= atan(2*O/L);
alpha= 3.2e-6;
E= 180e9;
w= 1.83e-6;
h= 2.5e-6;
I= (h*w^3)/12;
L_p_0 = (L/2)*(tan(theta))^2;
y_0= (L/2)*tan(theta);
%Calculation
for ii=1:length(T_init)
syms F1 real
k1= sqrt(F1/(E*I));
G= tan((k1*L)/4);
L_p = ((tan(theta))^2/(4*k1))*( 2*G + k1*L + k1*L*G^2 + sin(k1*L) - 2*G*cos(k1*L) - G^2*sin(k1*L));
delta_L_p = L_p - L_p_0;
stress(:,ii) = E*alpha*(T_set-T_init(ii));
sigma(:,ii)= (E/L)*(delta_L_p + ((F1*L)/(E*w*h)))== stress(:,ii);
F(:,ii)= vpasolve(sigma, [0 .4e-4]);
k(:,ii)= sqrt(F(:,ii)./(E*I));
y_a(:,ii)= 2.*(tan(theta)./k(:,ii)).*tan((k(:,ii).*L)./4);
delta_y(:,ii)= (double(y_a(:,ii)) - y_0)*1e6
end
0 comentarios
Respuesta aceptada
Walter Roberson
el 23 de Jul. de 2022
In the general case, you cannot.
You have to analyze the expression into numerator and denominator using numden(). Then you need to find the zeros of the denominator, as those are the locations of the discontinuities of the overall expression.
If the denominator is a polynomial of degree 4 or less then solve() can tell you the exact location of the zeros. If it is higher degree polynomial then vpasolve() can give you the approximate location of the zeros.
It looks to me at the moment as if likely your denominator would involve a trig term. That introduces an potentially infinite number of solutions, and finding the closed form solution can be difficult or impossible.
In the more general case, any given formula might involve the roots of a function for which there is no known way to find a solution. For example image a function which is everywhere 1 except at locations that are solutions to the Riemann Zeta function other than trivial zeros and complex part 1/2. What are the roots of the function? To know that you would have to find a constructive disproof of the Riemann Hypothesis, which absolutely no-one knows how to do (and which would have very important theoretical consequences.)
Possibly if you were to analyze your particular function you might be able to come up with a practical estimate of the search range, but there is no general way to do so for all problems.
2 comentarios
Walter Roberson
el 25 de Jul. de 2022
D_T = 0:25:500;
That is a vector
T_set= D_T+T_init(1);
So that is a vector
for ii=1:length(T_init)
syms F1 real
That is a scalar symbol
stress(:,ii) = E*alpha*(T_set-T_init(ii));
vector T_set so the right hand side is a vector, and it is being assigned into a column of an array which is okay in itself.
sigma(:,ii)= (E/L)*(delta_L_p + ((F1*L)/(E*w*h)))== stress(:,ii);
Vector of expressions on the right hand side of the == so the result is a vector of expressions, and it is being assigned into a column of an array which is okay in itself.
F(:,ii)= vpasolve(sigma, [0 .4e-4]);
You are asking to solve the entire sigma array that has been constructed so far. Not just the column you just constructed: all previous columns as well.
Each of the entries in each of the columns is an equality expression involving the scalar variable F1, so you are asking vpasolve() to solve an entire array of expressions for a single scalar value that has to satisfy all of the equations simultaneously. Every once in a while you end up with a single value such as 0 satisfying all entries of an array simultaneously, but the great majority of the time you have made an error by asking to do this.
Remember that solve() and vpasolve() exist to solve simultaneous equations. If you ask to solve(3*a+4*b==5, 7*a-2*b==11) then you are not asking to find the set of (a,b) that solve either equation, you are asking which a and b satisfy both equations at the same time.
If you have an array or vector of equations in a single variable, you typically need to use a loop or use arrayfun() to solve each of the equations in turn.
Más respuestas (0)
Ver también
Categorías
Más información sobre Equation Solving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!