How can I solve this nested symbolic function ?

1 view (last 30 days)
Hello, Im doing a metallurgical problem ,to do so I need to make the following code but returns an error when i call the following nested function, by the way I am doing so because I want to export it as an excel add-in .
valor=molienda(10,6,6,6.1,1.02,0.45,0.7,10)
Error using assignin
Attempt to add "z" to a static workspace.

Error in syms (line 262)
assignin('caller', x, xsym);

Error in solution>molienda/mP80 (line 17)
syms Q(x) z

Error in solution>molienda (line 5)
p80=mP80(t);
function a=molienda(F_min,Diametro,Largo,Wi,F80,Vp,fVc,t)
p80=mP80(t);
%Potencia para moler el mineral
W_mineral=Wi*((10/(p80^0.5))-(10/(F80))^(0.5));
P_mineral=W_mineral*F_min*1.341;
%Potencia para mover el medio moledor
Kwb = 4.879*(D^0.3)*(3.2-3*Vp)*fVc*(1-0.1/((2^9)-10*fVc))
W_bolas=80*(Diametro^2)*Largo;
P_bolas=Kwb*W_bolas;
P_total=P_bolas+P_mineral;
a(1)=P_total;
a(2)=P80;
function P_80=mP80(tiempo)
syms Q(x) z
Q(x) = (16.4831*x^(-0.7510)+1.665)*exp(-0.9451*tiempo^0.296);
fun= 80-(100-Q(z))==0;
P_80 = double(solve(fun,z));
end
end
I can´t find the solution ,please if you know how to i would very pleased . Thanks in advance for your help.

Accepted Answer

Star Strider
Star Strider on 16 Oct 2023
It would be best to abandon the idea of using the Symbolic Math Toolbox here, since it is not necessary. You can do everything necessary with anonymous functions.
Also, there are discrepancies between the function arguments and the code. I substituted ‘p80’ for ‘F80’ and ‘P80’ in order to make it work. You need to edit ‘molienda’ to resolve all these discrepancies, since I am not certain that the changes I made to it get it to work are correct.
Try this —
valor=molienda(10,6,6,6.1,1.02,0.45,0.7,10)
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
Kwb = 10.8133
valor = 1×2
1.0e+05 * 1.8904 0.0000
function a=molienda(F_min,Diametro,Largo,Wi,p80,Vp,fVc,t)
p80=mP80(t);
%Potencia para moler el mineral
W_mineral=Wi*((10/(p80^0.5))-(10/(p80))^(0.5));
P_mineral=W_mineral*F_min*1.341;
%Potencia para mover el medio moledor
Kwb = 4.879*(Diametro^0.3)*(3.2-3*Vp)*fVc*(1-0.1/((2^9)-10*fVc))
W_bolas=80*(Diametro^2)*Largo;
P_bolas=Kwb*W_bolas;
P_total=P_bolas+P_mineral;
a(1)=P_total;
a(2)=p80;
function P_80=mP80(tiempo)
% syms Q(x) z
Q = @(x) (16.4831*x.^(-0.7510)+1.665)*exp(-0.9451*tiempo.^0.296);
fun = @(z) 80-(100-Q(z));
P_80 = fsolve(fun,10);
end
end
.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!