How to facilitate the input of syms (automatization)

2 ビュー (過去 30 日間)
Delia Bosshart
Delia Bosshart 2021 年 6 月 20 日
コメント済み: Delia Bosshart 2021 年 6 月 20 日
Hi there. I would liket to automatize the syms input in my code such that I wouldn't have to list each sym from x1 to x21. The thing is that I also have iterations with x1 to x100 which almost makes it unbearable having to list all these syms.
The number of syms is always connected to t_end such that x1 x2 x3 .... xt_end. In this case t_end is equal to 21. Is there a way to connect these two?
syms x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21
x = [x2;x3;x4;x5;x6;x7;x8;x9;x10;x11;x12;x13;x14;x15;x16;x17;x18;x19;x20;x21];
T1 = [];
T2 = [];
t_end = length(t) -1;
for k=2:t_end
a = trapz(t(k:k+1),q_ext(k:k+1))/(t(k+1)-t(k));
b = trapz(t(k:k+1),q_losses(k:k+1))/(t(k+1)-t(k));
c = trapz(t(k:k+1),beta_ch(k:k+1))/(t(k+1)-t(k));
d = h_ch + (x(k-1)-c).*(t(k+1)-t(k));
e = 232.87.*d.^(-0.46);
gamma_mean = (gamma(k)+gamma(k+1))/2;
eqn = (a + b + gamma_mean*6.96.*x(k-1) + (6-(31*e)/1000).*x(k-1)/60*1000 + 31.*e/1000.*c/60*1000)*0.0077 - 0.0424 - x(k-1) == 0;
vpasolve(eqn, x(k-1));
beta = double(vpasolve(eqn, x(k-1)));

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 20 日
syms x [1,t_end]
x = x(2:end) ; %remove x1
  1 件のコメント
Delia Bosshart
Delia Bosshart 2021 年 6 月 20 日
it works, thank you!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEquation Solving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by