MATLAB Answers

How to facilitate the input of syms (automatization)

2 views (last 30 days)
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)));

More Answers (0)

Community Treasure Hunt

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

Start Hunting!