Filter löschen
Filter löschen

Using subs in a matrix of equations

5 Ansichten (letzte 30 Tage)
Anthony Sirico
Anthony Sirico am 6 Mär. 2021
Kommentiert: Anthony Sirico am 6 Mär. 2021
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;

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Mär. 2021
%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 = 

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by