Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

2 次查看(过去 30 天)
syms X;
n = length(a) ;
for i=1:n
Tdet1(i) = sqrt(2*a(i)/D(i)*h(i));
FZ(i) = 1-((Tdet1(i).*((cn.*Y(i))+h(i)))./(B(i))); %((cn.*Y(i).+h(i)).*(Tdet(i)./B(i))) ; % Acumulado
alfa(i) = 1-FZ(i) ; % Nivel de Servicio con Tdet
Z(i) = (norminv(1-alfa(i)/2)) ;
fz(i) = normpdf(Z(i)) ; %%abs(0.5-alfa(i)) ; % Función de densidad normal con Z(Tdet)
Tdet(i) = solve ((-a(i)/X^2)+((D*h(i))/2)+ ...
((Z(i)*sg(i))/(2*sqrt(X+L(i))))+ ...
(sg(i)*fz(i))*((((-B(i))*X^2)- ...
(2*X*B(i)*L(i)))/((2*X^3)*sqrt(X+L(i))))- ...
((sg(i)*Z(i))*(((2*L(i)-X)*(((X)*(cn(i)))*Y(i))+ ...
((X)*h(i))))/(2*sqrt(X+L(i))))+((((cn(i))*Y(i))*sqrt(X+L(i)))/X))== 0,X;

回答(1 个)

Bhavana Ravirala
Bhavana Ravirala 2022-2-15
Hi Yineth,
From my understanding, at every iteration the code produces more than one solution for X. So, storing the output in a cell array will eliminate this error.
Tdet{i} = solve ((-a(i)/X^2)+((D*h(i))/2)+ ...
((Z(i)*sg(i))/(2*sqrt(X+L(i))))+ ...
(sg(i)*fz(i))*((((-B(i))*X^2)- ...
(2*X*B(i)*L(i)))/((2*X^3)*sqrt(X+L(i))))- ...
((sg(i)*Z(i))*(((2*L(i)-X)*(((X)*(cn(i)))*Y(i))+ ...
((X)*h(i))))/(2*sqrt(X+L(i))))+((((cn(i))*Y(i))*sqrt(X+L(i)))/X))== 0,X;
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by