Error in assigning value to variable while solving non-linear equations using syms

1 次查看(过去 30 天)
I am trying to solve some non-linear equations. While running I am getting error as follows. May I please know what exactly this error means( as I need min positive value from all the solutions) and it can be resolved
Unable to perform assignment because the left and right sides have a different number of elements.
Error in SpeciationCal (line 29)
n(i)=min(S.b)
syms a b c
x3=[0.000804557 0.038813753 0.109515494 0.258253623 0.250365943 0.266695352 0.254064153 0.355464596 0.367390937 0.367899743];
x1=[0.812965986 0.75197909 0.647030256 0.315659359 0.381316826 0.324185571 0.385450182 0.198472313 0.161364552 0.181784492];
x2=[0.186229457 0.209207157 0.243454249 0.426087018 0.368317231 0.409119077 0.360485665 0.446063091 0.47124451 0.450315765];
T=[384.2 392.1 396.4 392 406.1 405 409.6 416.2 416.4 417.1];
N=length(x1);
K1=zeros(N,1);K2=zeros(N,1);K3=zeros(N,1);m=zeros(N,1);n=zeros(N,1);o=zeros(N,1);
for i=1:N
K1(i)=exp((-936.28)+((40216.27)/T(i))+(151.983*(log(T(i))))+(-0.1675*(T(i))))
K2(i)=exp((1044.78)+(-45171.42/T(i))+(-165.20*log(T(i))+(0.1511*(T(i)))))
K3(i)=exp((-228.838)+(12587.48/T(i))+(40.68593*log(T(i)))+(-0.09838*(T(i))))
eqns=[((a*(a-b))/((x1(i)-a-c+3*b)*(x2(i)-a-c)))==K1(i),((b*3*b)/(a-b)*(x3(i)-b))==K2(i),((c*c)/((x1(i)-a-c+3*b)*(x2(i)-a-c)))==K3(i)]
S=vpasolve(eqns,[a,b,c])
warning('off', 'symbolic:numeric:NumericalInstability')
S.a(S.a<0)=[];
S.b(S.b<0)=[];
S.c(S.c<0)=[];
idxa= abs(imag(S.a)) < eps;
idxb = abs(imag(S.b)) < eps;
idxc = abs(imag(S.c)) < eps;
S.a = S.a(idxa);
S.b = S.b(idxb);
S.c = S.c(idxc);
m(i)=min(S.a)
n(i)=min(S.b)
o(i)=min(S.c)
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by