Solving a symbolic system of equations

2 次查看(过去 30 天)
I'm trying to solve a symbolic system of equations in MATLAB, but it keeps giving me zero for the variables I'm solving for. I know this isn't the answer since I worked the problem out by hand. Is there a way to use the solve function to do this?
% Equillateral Strain Rosette Problem
% angle values (A = 0, B = 120; C =60; seems to be standard for a 60 degree
% equilateral triangle)
A = 0;
B = 120;
C = 60;
% Given Angles
ThetaA = deg2rad(A); %radians for A, it always seems to start at 0
ThetaB = deg2rad(B); %in an equillateral triangle seems to be 180-interior angle
ThetaC = deg2rad(C); %seems to be just interior angle
syms strainx strainy strainxy strainA strainB strainC
strainA = (strainx+strainy)/2 + (strainx-strainy)/2*cos(2*ThetaA) + strainxy*sin(2*ThetaA);
strainB = (strainx+strainy)/2 + (strainx-strainy)/2*cos(2*ThetaB) + strainxy*sin(2*ThetaB);
strainC = (strainx+strainy)/2 + (strainx-strainy)/2*cos(2*ThetaC) + strainxy*sin(2*ThetaC);
eqns = [strainA, strainB, strainC];
vars = [strainx, strainy, strainxy];
[strainx, strainy, strainxy] = solve(eqns,vars); %Need to solve in terms of strainA strainB and strainC

采纳的回答

Stephan
Stephan 2020-10-23
Try:
% Equillateral Strain Rosette Problem
% angle values (A = 0, B = 120; C =60; seems to be standard for a 60 degree
% equilateral triangle)
A = 0;
B = 120;
C = 60;
% Given Angles
ThetaA = deg2rad(A); %radians for A, it always seems to start at 0
ThetaB = deg2rad(B); %in an equillateral triangle seems to be 180-interior angle
ThetaC = deg2rad(C); %seems to be just interior angle
syms strainx strainy strainxy strainA strainB strainC
eq(1) = strainA == (strainx+strainy)/2 + (strainx-strainy)/2*cos(2*ThetaA) + strainxy*sin(2*ThetaA);
eq(2) = strainB == (strainx+strainy)/2 + (strainx-strainy)/2*cos(2*ThetaB) + strainxy*sin(2*ThetaB);
eq(3) = strainC == (strainx+strainy)/2 + (strainx-strainy)/2*cos(2*ThetaC) + strainxy*sin(2*ThetaC);
vars = [strainx, strainy, strainxy];
[strainx, strainy, strainxy] = solve(eq,vars) %Need to solve in terms of strainA strainB and strainC
which gives:
strainx =
strainA
strainy =
(2*strainB)/3 - strainA/3 + (2*strainC)/3
strainxy =
-(3^(1/2)*(strainB - strainC))/3

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by