Effacer les filtres
Effacer les filtres

Using subs in a matrix of equations

5 vues (au cours des 30 derniers jours)
Anthony Sirico
Anthony Sirico le 6 Mar 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;

Réponse acceptée

Walter Roberson
Walter Roberson le 6 Mar 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 = 

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by