フィルターのクリア

Solve matrix with different symbolic variable

2 ビュー (過去 30 日間)
Milan
Milan 2022 年 10 月 30 日
回答済み: Ishu 2023 年 9 月 8 日
%Hello, I tried to solve this matrix problem to get solutioon interms of E, R, and I which is not known. I could get %it by putting values of E, I and R as 1 randomly, but could not get interms of E, R, and I. Does anybody has idea %to solve it?
%Igonoring shear deformation, the element stiffness matrix in local
%coordination for element 1
clc;
clear;
close;
%syms A;
syms R;
syms phi real;
syms E;
syms I_z
E = 1;
I_z = 1;
%E_Iz = E*I_z;
R = 1;
L = R; %R
%A = 1;
A = 100000000000;
% K1 = A*E/L;
% K2 = 12*E*I_z/L^3;
% K3= 6*E*I_z/L^2;
% K4 = 4*E*I_z/L;
% K5 = 2*E*I_z/L;
% for element 1
Ke_1_local = [A*E/L 0 0 -A*E/L 0 0;
0 12*E*I_z/L^3 6*E*I_z/L^2 0 -12*E*I_z/L^3 6*E*I_z/L^2;
0 6*E*I_z/L^2 4*E*I_z/L 0 -6*E*I_z/L^2 2*E*I_z/L;
-A*E/L 0 0 A*E/L 0 0;
0 -12*E*I_z/L^3 -6*E*I_z/L^2 0 12*E*I_z/L^3 -6*E*I_z/L^2;
0 6*E*I_z/L^2 2*E*I_z/L 0 -6*E*I_z/L^2 4*E*I_z/L ];
% Ke_1_local= [A 0 0 -A 0 0;
% 0 12 6 0 -12/L^3 6;
% 0 6 4 0 -6 2;
% -A 0 0 A 0 0;
% 0 -12 -6 0 12 -6;
% 0 6 2 0 -6 4];
%%
% transformation matrix Gamma
Phi = 90;
gamma_1 = [cosd(Phi) sind(Phi) 0 0 0 0;
-sind(Phi) cosd(Phi) 0 0 0 0;
0 0 1 0 0 0 ;
0 0 0 cosd(Phi) sind(Phi) 0;
0 0 0 -sind(Phi) cosd(Phi) 0;
0 0 0 0 0 1];
%element stiffness matrix in global coordinate
Ke_1_global = gamma_1'.*Ke_1_local.*gamma_1;
%For arch
%Element 2
phi_1 = 0;
phi_2 = pi/2;
%equillibrium matrix
phi2 = [-1 0 0;
0 -1 0;
-R*(sin(phi_2)-sin(phi_1)) R*(cos(phi_1)-cos(phi_2)) -1];
%flexibility matrix
Q_b = @(phi) [-R*(sin(phi)-sin(phi_1)) R*(cos(phi_1)-cos(phi)) -1];
d2 = @(phi) (Q_b(phi)'.*Q_b(phi))./(E*I_z);
d2_phi = d2(phi);
d2_int = int(d2_phi, phi, 0, pi/2);
d_3 = vpa(d2_int);
%Siffness matrix
Kff_3 = inv(d_3);
Kfs_3 = inv(d_3)*phi2';
Ksf_3 = phi2*inv(d_3);
Kss_3 = phi2*inv(d_3)*phi2';
Ke_2_global = round([Kff_3 Kfs_3; Ksf_3 Kss_3], 2);
%Element3
phi_1 = pi/2;
phi_2 = 3*pi/4;
%equillibrium matrix
phi2 = [-1 0 0;
0 -1 0;
-R*(sin(phi_2)-sin(phi_1)) R*(cos(phi_1)-cos(phi_2)) -1];
%flexibility matrix
Q_b = @(phi) [-R*(sin(phi)-sin(phi_1)) R*(cos(phi_1)-cos(phi)) -1];
d3 = @(phi) (Q_b(phi)'.*Q_b(phi))./(E*I_z);
d3_phi = d3(phi);
d3_int = int(d3_phi, phi_1, phi_2);
d_3 = vpa(d3_int);
%Siffness matrix
Kff_3 = inv(d_3);
Kfs_3 = inv(d_3)*phi2';
Ksf_3 = phi2*inv(d_3);
Kss_3= phi2*inv(d_3)*phi2';
Ke_3_global = round([Kff_3 Kfs_3; Ksf_3 Kss_3], 2);
%assemble local stiffness matrix
B = {[1 2], [2,3], [3,4]};
nele = 3; %number of element
ndof = 3; %number of dof perelement
%element topology
Edof = [1 1 2 3 4 5 6
2 4 5 6 7 8 9
3 7 8 9 10 11 12];
%the system matrices i.e the stiffness matrix K and load vector f
P = 1;
K = zeros(12);
f = zeros(12, 1);
f(4,:) = P;
f(8,:) = -P;
K = assem(Edof(1,:),K,Ke_1_global);
K = assem(Edof(2,:),K,Ke_2_global);
K = assem(Edof(3,:),K,Ke_3_global)
fdof = ([4,5,6,7,8,9]);
sdof = ([1,2,3,10,11,12]);
F_f = [P 0 0 0 -P 0]';
K_ff = K(fdof,fdof);
delta_f = inv(K_ff)*F_f %solveq(inv(K_ff),F_f)

回答 (1 件)

Ishu
Ishu 2023 年 9 月 8 日
Hi Milan,
As you have not provided the 'assem()' function so I was not able to reproduce the error at my end.
But as I can see at the calling of your 'assem()' function that you are providing three arguments to the function, two are the normal matrices containing constant values and the third one "Ke_1_global" contains symbolic variables.
Therefore, I assume that you want to solve "Ke_1_global" symbolic matrix with other two normal matrices.
A general solution to this case is that you can use in-built MATLAB function "solve()".
% This is just an example
syms E R I
% Define the matrix equation
A = [2, 3, 4;
5, 6, 7;
8, 9, 10];
b = [E; R; I];
% Solve the matrix equation
solution = solve(A * b, [E, R, I]);
% Access the solution values
E_solution = solution.E;
R_solution = solution.R;
I_solution = solution.I;
For more information you can refer these documentations:
You can also check out this MATLAB Answers, this one is also related to "solving symbolic matrix":
Hope it helps!

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by