How to change values for variables that are defined in a equation
47 ビュー (過去 30 日間)
古いコメントを表示
Hello everybody!
I have an equation depending on several variables (a, b, c, d) . By defining the values new and wanting the adapted output, it still takes the values for the variables that I defined first (for fist and second set the output is x=1.4321). How can I ressolve that? I dont want to change the names of the variables as I have more than 80 different values for the same variable.
See my code:
%first set of values for variables
a = 75; %q_inc
b = 13.8; %q_losses
c = 73; %rho_char
d = 1.02; %betta_char
syms x
eqn = (a - b + 6.96*x + (6-(31*c)/1000)*x/60*1000 + 31*c/1000*d/60*1000)*0.0081 - 0.1824 -x == 0;
vpasolve(eqn,x)
ans = 1.4231
%second set of values for variables
a = 96.4; %q_inc
b = 14.1; %q_losses
c = 100.6; %rho_char
d = 1.32; %betta_char
vpasolve(eqn,x)
ans = 1.4231
0 件のコメント
採用された回答
Walter Roberson
2021 年 4 月 19 日
syms a b c d
syms x
eqn = (a - b + 6.96*x + (6-(31*c)/1000)*x/60*1000 + 31*c/1000*d/60*1000)*0.0081 - 0.1824 -x == 0;
sol = solve(eqn, x)
A = [75, 96.4];
B = [13.8, 14.1];
C = [73, 100.6];
D = [1.02, 1.32];
subs(sol, {a,b,c,d}, {A,B,C,D})
0 件のコメント
その他の回答 (2 件)
Alan Stevens
2021 年 4 月 16 日
Since your equation is linear in x it's probably best to rewrite as in the following, and put all your a,b,c,d vaues into vectors:
a = [75, 96.4];
b = [13.8, 14.1];
c = [73, 100.6];
d = [1.02, 1.32];
x = ((a - b + 31*c/1000.*d/60*1000)*0.0081 - 0.1824)./(1 - 0.0081*(6.96 + (6-31*c/1000)/60*1000));
disp(x)
Alan Stevens
2021 年 4 月 19 日
More like this perhaps (of course you will need to use your on values for the constants):
a = [75, 96.4];
b = [13.8, 14.1];
c = [73, 100.6];
d = [1.02, 1.32];
e = [0.1, 0.2]; t = [0.3, 0.4]; % replace with your values
syms x
for i = 1:numel(a)
eqn2 = (a(i) - b(i) + 6.96*x + (6-(31*232.87*((x-e(i))*t(i))^(-0.46))/1000)*x/60*1000 + 31*d(i)/1000*e(i)/60*1000)*0.0081 - 0.1824 -x == 0;
y = vpasolve(eqn2,x);
disp(y)
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Special Values についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!