MATLAB: How to skip vpasolve empty sym inside a loop

MATLABvpasolve

Hello,
I have the below code which numerically solves my equation in hand. The vpasolve breaks down when no solution is found. This is due to both a lower or higher values of B. When I change the range of B to let say 30:1:180, the loop runs without problems. However, I need to know the values of B that leads to no solution in addition to the solution. I want the loop to save this particular value to zero and continue to the end. Below is the code:
clear
clc
syms Re Nu Cd
B = 1:1:200;
h = 0.1;
Cd = (-1.9151e-08*((Re^3)*h)) + (2.4399e-09*(Re^3)) - (5.5447e-05*((Re^2)*(h^2))) + (5.7480e-05*((Re^2)*h)) - (6.1862e-06*(Re^2)) - (0.2113*(Re*(h^3))) + (0.1933*(Re*(h^2))) - (0.0695*Re*h) + (0.0057*Re) + (403.4544*(h^4)) - (258.2577*(h^3)) + (45.9552*(h^2)) + (1.4336*h) + (0.9849);
Nu = (-1.1182e-05*(Re^2)) + (0.0024*Re*h) + (0.0299*Re) - (79.0558*(h^2)) + (55.9753*h) - (5.8551);
sol_Re = zeros();
for i = 1:length(B)
sol_Re(i) = vpasolve(Nu*Cd*Re==(2.*B(i).^2)./pi,[100 1000],'Random',true);
end

Best Answer

Store the result of vpasolve into a variable. Test to see if it is empty before storing into the matrix.