フィルターのクリア

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 = 
  1 件のコメント
Anthony Sirico
Anthony Sirico 2021 年 3 月 6 日
Thanks alot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by