substitute value for variable
Afficher commentaires plus anciens
I have created a code to solve a differential in terms of one variable (all C variables and B are constants and defined previously). Now I want to plug a value in for that variable into the differential equation, but it won't let me. I tried using the 'subs' function, but that doesn't work. Help?
syms I1 I2
F1 = C1*(exp(C2*(I1-3)-1))-((C1*C2)/2)*(I2-3);
W1 = 0;
F2 = piecewise(x<1,W1,1<x<lambda,W2,x>lambda,W3);
Wo = F1 + F2;
Wo1 = diff(Wo,I1);
Wo2 = diff(Wo,I2);
clear I1 I2
I1 = trace(B);
I2 = .5*((trace(B))^2+trace(B^2));
subs(Wo1,I1,I2);
2 commentaires
Birdman
le 21 Fév 2018
Share all variables, the entire code.
Stephen23
le 21 Fév 2018
Here's the whole code. It all works until the last step.
% Define coefficients for all the fiber families
syms x p Wx I1 I2
pres = [p 0 0
0 p 0
0 0 p];
theta = [2 122 241];
C1 = .00124;
C2 = 1.07;
C3 = [1.03*10^-7 1.67*10^-7 1.59*10^-7];
C4 = [26.6 35 38];
lambda = [2.78 5.6 7.74];
C5 = C3.*C4.*lambda.*(exp(C4.*(lambda-1)));
% Define displacement matrix and B matrix
F = [x 0 0
0 1/sqrt(x) 0
0 0 1/sqrt(x)];
B = F*transpose(F);
% Define F1 as given
F1 = C1*(exp(C2*(I1-3)-1))-((C1*C2)/2)*(I2-3);
W1 = 0;
% Run pipline for each fiber family to get individual strain energy
% functions
for n = 1:3
a = [cos(theta(n))
-sin(theta(n))
0];
W2 = C3(n)*exp(C4(n)*(x-1))-1;
W3 = C5(n);
F2 = piecewise(x<1,W1,1<x<lambda(n),W2,x>lambda(n),W3);
Wo(n) = F1 + F2;
Wo1(n) = diff(Wo(n),I1);
Wo2(n) = diff(Wo(n),I2);
ao(n) = transpose(a(n))*a(n);
end
% Plug in values for a matrix and invariantes
clear I1 I2
I1 = trace(B);
I2 = .5*((trace(B))^2+trace(B^2));
%Substitute in the invariant values
for n=1:3
subs(Wo1(n),I1);
subs(Wo2(n),I2);
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Get Started with MuPAD dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!