Computing Matrices with Multiple Variables that are Unknown

Please utilized following code to optimize solutions for unknown variables. Only need assistance with %Solve Section
%% PS3 - 1A
clear all
%% Givens
L = 10 %in
L = 10
E = 10 * 10^6 %PSI
E = 10000000
w = .5 %in
w = 0.5000
I = (w^4)/12
I = 0.0052
%% k1 = k2
j = E*I/(L^3)
j = 52.0833
k = j * [12 6*L -12 6*L
6*L 4*L^2 -6*L 2*L^2
-12 -6*L 12 -6*L
6*L 2*L^2 -6*L 4*L^2]
k = 4x4
1.0e+04 * 0.0625 0.3125 -0.0625 0.3125 0.3125 2.0833 -0.3125 1.0417 -0.0625 -0.3125 0.0625 -0.3125 0.3125 1.0417 -0.3125 2.0833
%% K
K = [ k(1,1) k(1,2) k(1,3) k(1,4) 0 0
k(2,1) k(2,2) k(2,3) k(2,4) 0 0
k(3,1) k(3,2) (k(3,3) + k(1,1)) (k(3,4) + k(1,2)) k(1,3) k(1,4)
k(4,1) k(4,2) (k(4,3) + k(1,2)) (k(4,4) + k(2,2)) k(2,3) k(2,4)
0 0 k(1,3) k(2,3) k(3,3) k(4,3)
0 0 k(1,4) k(2,4) k(3,4) k(4,4)]
K = 6x6
1.0e+04 * 0.0625 0.3125 -0.0625 0.3125 0 0 0.3125 2.0833 -0.3125 1.0417 0 0 -0.0625 -0.3125 0.1250 0 -0.0625 0.3125 0.3125 1.0417 0 4.1667 -0.3125 1.0417 0 0 -0.0625 -0.3125 0.0625 -0.3125 0 0 0.3125 1.0417 -0.3125 2.0833
%% U
v1 = 0
v1 = 0
%v2 =
v3 = 0
v3 = 0
%t1 =
%t2 =
%t3 =
syms v2 t1 t2 t3
U = [v1 t1 v2 t2 v3 t3]'
U = 
%% F
q = 10 %lb/in
q = 10
F1R = 75 %lb RESULTANT FORCE
F1R = 75
F3R = 25 %lb RESULTANT FORCE
F3R = 25
F1 = F1R - (q*L)/4
F1 = 50
F2 = -(q*L)/4
F2 = -25
F3 = F3R
F3 = 25
M1 = -(q*L^2)/48
M1 = -20.8333
M2 = (q*L^2)/48
M2 = 20.8333
M3 = 0
M3 = 0
F = [F1 M1 F2 M2 F3 M3]'
F = 6x1
50.0000 -20.8333 -25.0000 20.8333 25.0000 0
%%Solve
Solved=solve(K.*U==F,[t1 v2 t2 t3])
Solved = struct with fields:
t1: [0x1 sym] v2: [0x1 sym] t2: [0x1 sym] t3: [0x1 sym]
vpaSolved = vpa(struct2cell(Solved))
vpaSolved = Empty sym: 0-by-1

5 个评论

@Walter Roberson code has been updated. That was for my reference.
You must decide which of the variables you want to prescribe and which you want to solve for:
Solved=solve(K.*U==F,[f1 f3 F1 F3 v1 v2 v3 t1 t2 t3])
f1 and f3 are unknown variables in your code, F1 and F3 are set to numerical values - thus needn't be solved for, v1 and v3 are set to numerical values - thus needn't be solved for.
@Torsten I have updated code to try to solve for desired values. I now have empty matrices?
Hi Romualdo,
I modified the code a bit to use all symbolic constants, real variables, and used transpose, .' instead of ctranspose, ' as it seemed that is the intent. The final equation to be solved used element-wise multiplication times, .* with singleton expansion instead of matrix mutliplication mtimes, *; the former results in an obviously inconsistent set of equations. Still can't find a solution.
L = sym(10); %in
E = sym(10) * 10^6; %PSI
%w = .5 %in
w = sym(1)/2;
I = (w^4)/12;
%% k1 = k2
j = E*I/(L^3);
k = j * [12 6*L -12 6*L
6*L 4*L^2 -6*L 2*L^2
-12 -6*L 12 -6*L
6*L 2*L^2 -6*L 4*L^2];
%% K
K = [ k(1,1) k(1,2) k(1,3) k(1,4) 0 0
k(2,1) k(2,2) k(2,3) k(2,4) 0 0
k(3,1) k(3,2) (k(3,3) + k(1,1)) (k(3,4) + k(1,2)) k(1,3) k(1,4)
k(4,1) k(4,2) (k(4,3) + k(1,2)) (k(4,4) + k(2,2)) k(2,3) k(2,4)
0 0 k(1,3) k(2,3) k(3,3) k(4,3)
0 0 k(1,4) k(2,4) k(3,4) k(4,4)];
%% U
v1 = 0;
v3 = 0;
% assume real
syms v2 t1 t2 t3 real
% use transpose
U = [v1 t1 v2 t2 v3 t3].' ;
%% F
q = sym(10); %lb/in
F1R = sym(75); %lb RESULTANT FORCE
F3R = sym(25); %lb RESULTANT FORCE
F1 = F1R - (q*L)/4;
F2 = -(q*L)/4;
F3 = F3R;
M1 = -(q*L^2)/48;
M2 = (q*L^2)/48;
M3 = 0;
% use transpose
F = [F1 M1 F2 M2 F3 M3].' ;
Here's the equation to solve. It appears to not be correctly formulated, just by looking at the first row.
%%Solve
K.*U == F
ans = 
The preceding equation used element-wise multiplication. Maybe matrix multiplication was intended?
K*U == F
ans = 
Though these six equations in four unknowns also don't have a solution.
Solved=solve(K*U==F,[t1 v2 t2 t3])
Solved = struct with fields:
t1: [0x1 sym] v2: [0x1 sym] t2: [0x1 sym] t3: [0x1 sym]

请先登录,再进行评论。

回答(0 个)

类别

标签

编辑:

2024-3-12

Community Treasure Hunt

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

Start Hunting!

Translated by