Hello,
I am trying to solve the a matrix using solve function, not able to figure it out.
clear all
clc
syms x1 x2 M k L dx1 dx2 p
% Displacement of the bar
xg=(x1+x2)/2;
% Rotation of the bar
thi=(x2-x1)/L;
%moment of inertia
J=M*L^2/12;
dxg=(dx1+dx2)/2;
dthi=(dx2-dx1)/L;
% Kinetic energy
KE=0.5*((M*dxg^2)+(J*dthi^2));
% Potenial Engergy
PE=0.5*(2*k*x1^2+3*k*x2^2);
u=[x1 x2];
du=[dx1;dx2];
s=solve(KE==0.5.*transpose(du)*p*du);

댓글 수: 3

Walter Roberson
Walter Roberson 2019년 3월 17일
s = solve(EXPRESSION, p)
LOKESH UDATHA
LOKESH UDATHA 2019년 3월 18일
Thanks a lot, but a small problem
my p is a 2*2 matrix but I am getting sloution as a scalar.
Walter Roberson
Walter Roberson 2019년 3월 18일
No it isn't . u is 1 x 2 so transpose of u is 2 x 1. You cannot do 2 x 1 * 2 x 2 * 1 x 2 because none of the inner dimensions match. Your u would have to be 2 x 1 to fix that .
There is not enough information to isolate 2 x 2 p.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sajeer Modavan
Sajeer Modavan 2019년 3월 17일

0 개 추천

Since you are solving with for p, result of 's' equal to 'p'
to confirm this, you can use following code (which is same as yours, but forcefully solving for 'p')
P = solve(KE==0.5.*transpose(du)*p*du,p);

댓글 수: 1

LOKESH UDATHA
LOKESH UDATHA 2019년 3월 18일
Thanks a lot for replying,
but my p is a 2*2 matrix but I am getting p as a scalar.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Interactions, Camera Views, and Lighting에 대해 자세히 알아보기

태그

질문:

2019년 3월 17일

댓글:

2019년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by