Azzera filtri
Azzera filtri

Solve a system of equations for a closed form with a parameter

2 visualizzazioni (ultimi 30 giorni)
I am very new to this discussion forum. I want to solve for unknown variable X1,X2,X3,X4 which varies for different values of X5. With hand calculation i am able to come up with a solution of y. But unable to do so in MATLAB. Following is the code. Thank you in advance
clc
clear all
L=1
L = 1
syms X1 X2 X3 X4 X5 x;
V= [X1 X2 X3 X4]';
s= [sin(X5*x) cos(X5*x) sinh(X5*x) cosh(X5*x)]
s = 
s1= diff(s,x);
s2= diff(s,x,2);
s3= diff(diff(s,x,2),x,1);
V1= subs(s,x,0)
V1 = 
V2= subs(s1,x,0)
V2 = 
V3= subs(s,x,L)
V3 = 
V4= subs(s1,x,L)
V4 = 
e0 = V1*V == 0;
e1 = V2*V ==0;
e2 = V3*V ==0;
e3 = V4*V ==0
e3 = 
sol027 = solve([e0, e1, e2,e3], [X1, X2, X3, X4, X5]) %Where y=s*V;
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
sol027 = struct with fields:
X1: 0 X2: 0 X3: 0 X4: 0 X5: 0

Risposte (1)

Walter Roberson
Walter Roberson il 6 Feb 2022
According to your description, your X5 is an input constant. You should not be trying to solve for X5 -- you are trying to solve 4 equations for 5 variables, one of which is an input.
L=1
L = 1
syms X1 X2 X3 X4 X5 x real
V= [X1 X2 X3 X4]';
s= [sin(X5*x) cos(X5*x) sinh(X5*x) cosh(X5*x)]
s = 
s1= diff(s,x);
s2= diff(s,x,2);
s3= diff(diff(s,x,2),x,1);
V1= subs(s,x,0)
V1 = 
V2= subs(s1,x,0)
V2 = 
V3= subs(s,x,L)
V3 = 
V4= subs(s1,x,L)
V4 = 
e0 = V1*V == 0
e0 = 
e1 = V2*V ==0;
e2 = V3*V ==0;
e3 = V4*V ==0;
eqn = [e0, e1, e2,e3].'
eqn = 
sol027 = solve(eqn, [X1, X2, X3, X4]) %Where y=s*V;
sol027 = struct with fields:
X1: 0 X2: 0 X3: 0 X4: 0
You can see by examination that X1 = X2 = X3 = X4 satisfies the equations.
  1 Commento
Aninda pal
Aninda pal il 6 Feb 2022
Thank you sir for your kind response. But i may not have been good in delivering what i actually wanted to convey. I meant X5 to be a variable (all Xs). I finally did solve this problem few part left. I actually did not consider null space. However thank you for you hard work again. I got the solution. Actually all of it i did on smartphone so it was not in proper format. Following is the code still some of it is left.
clc clear all A = sym('a', [1 20]); syms ang x; angm=[sin(ang*x) cos(ang*x) sinh(ang*x) cosh(ang*x)]; angmd1= diff(angm,x); angmd2= diff(angm,x,2); angmd3= diff(diff(angm,x,2),x,1);
rv= zeros(4,1);
L1=subs(angm,x,0); L2=subs(angmd1,x,0); L3=subs(angm,x,4); L4=subs(angmd1,x,4); Lm=[L1;L2;L3;L4]; %solve(det(Lm) == 0)
%null(Lm) fun1=matlabFunction(simplify(det(Lm)))
for k1 = 1:500 s(k1) = fzero(fun1, k1/10); end su = unique(round(abs(s), 5)); Output = su(1:5)

Accedi per commentare.

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by