필터 지우기
필터 지우기

Using subs in a matrix of equations

조회 수: 5 (최근 30일)
Anthony Sirico
Anthony Sirico 2021년 3월 6일
댓글: Anthony Sirico 2021년 3월 6일
If i have a matrix of eqns, how can i sub in certain letter values now. I am using a live script where the first section creates the matrix, the second section i want to sub in the values of the constants.
%section1
close all; clear; clc;
syms A C0 Dv ka kh kt x1 x2 x3 x4 v1 v2 v3 u1 u2
%each element of the linearizes matrix
f1 = 1/A * (ka*(u1+u2)-C0*sqrt(x1-x2));
f2 = 1/A * (C0*sqrt(x1-x2)-Dv*sqrt(x2)*v1);
f3 = 1/(A*x1) * ((v2-x3)*ka*u1+(v3-x3)*ka*u2);
f4 = 1/(A*x2) * (x3-x4)*C0*sqrt(x1-x2);
AJ = jacobian([f1;f2;f3;f4],[x1 x2 x3 x4])
BJ = jacobian([f1;f2;f3;f4],[u1 u2])
BvJ = jacobian([f1;f2;f3;f4],[v1 v2 v3])
CJ = [0 kh 0 0;
0 0 0 kt]
%section 2
A = 0.785;
Dv = 2.66;
C0 = 0.056;
ka = 0.004;
kh = 2;
kt = 0.1;

채택된 답변

Walter Roberson
Walter Roberson 2021년 3월 6일
%section1
close all; clear; clc;
syms A C0 Dv ka kh kt x1 x2 x3 x4 v1 v2 v3 u1 u2
%each element of the linearizes matrix
f1 = 1/A * (ka*(u1+u2)-C0*sqrt(x1-x2));
f2 = 1/A * (C0*sqrt(x1-x2)-Dv*sqrt(x2)*v1);
f3 = 1/(A*x1) * ((v2-x3)*ka*u1+(v3-x3)*ka*u2);
f4 = 1/(A*x2) * (x3-x4)*C0*sqrt(x1-x2);
AJ = jacobian([f1;f2;f3;f4],[x1 x2 x3 x4])
AJ = 
BJ = jacobian([f1;f2;f3;f4],[u1 u2])
BJ = 
BvJ = jacobian([f1;f2;f3;f4],[v1 v2 v3])
BvJ = 
CJ = [0 kh 0 0;
0 0 0 kt]
CJ = 
%section 2
A = 0.785;
Dv = 2.66;
C0 = 0.056;
ka = 0.004;
kh = 2;
kt = 0.1;
%section 3
subs(AJ)
ans = 
subs(BJ)
ans = 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by