How to solve a system of linear equations in a matrix (KX=W) where all values of W are known and some value's of X are known?
5 次查看(过去 30 天)
显示 更早的评论
A = 8x8 matrix with all values known
X = 8x1 matrix with 3 values known
W = 8x1 matrix with all values known
I've seen some similar posts but I'm still a beginner with matlab so im having trouble understanding them.
num_elem=3
E=70
I=2340*10^6
for i=1:num_elem
if i==1
L=5
elseif i==2
L=5
elseif i==3
L=4
end
k{i}=[12, 3*L, -12, 3*L;
3*L, L^2, -3*L, L^2/2;
-12, -3*L, 12, -3*L;
3*L, L^2/2, -3*L, L^2;]*(E*I/L^3);
sprintf('This is matrix k%d.', i)
k{i}
end
matn=8;
matm=8;
K=zeros(matm,matn);
for n=1:num_elem
for a=1:4
for b=1:4
K(a+((n-1)*2),b+((n-1)*2))=K(a+((n-1)*2),b+((n-1)*2))+k{n}(a,b);
end
end
end
K
W=[0;0;-180000;0;-30000;-5000000;-30000;-5000000]
X=[0;r1;v2;r2;0;r3;v4;r4]
1 个评论
回答(1 个)
Shashank Gupta
2021-1-7
Hi Carmelo,
There are many ways to attack this problem. Simplest way is to just ignore the known variables and solve the equation by considering all the variable in X as unknown. So the X will simply be
X = inv(A)*W;
and then check the known variable in X satisy this equation. if they do well and good. if they don't then there is some mistake you did while forming the equations. Because the following equation must satisfy in the way you formed it.
I hope this helps you.
Cheers
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!