Unable to perorm assignment

Rf(CA+1)=(solve( Vb(CA+1) == pi *( r_cyl^2 * zw(CA) + ( za(CA) -zw(CA) )* (x^2) - ( za(CA)^3 - zw(CA)^3 )/3 ) ,x))
It says unable to perform assignment since left and right side have different elements.Can anyone help us out?

 Accepted Answer

Walter Roberson
Walter Roberson on 28 Dec 2020
The equation involves x^2 so you should expect an even number of solutions not one solution.

2 Comments

Thanks for your response
What if I want to store the positive root for x in Rf(CA+1)?
The below code allows for a small bit of imaginary component due to numeric round-off. You might need to adust the tolerance.
tol = 1e-12;
temp = solve( Vb(CA+1) == pi *( r_cyl^2 * zw(CA) + ( za(CA) -zw(CA) )* (x^2) - ( za(CA)^3 - zw(CA)^3 )/3 ) ,x);
temp( abs(imag(temp)) > tol || real(temp) < 0) = [];
temp = real(temp);
if isempty(temp)
Rf(CA+1) = nan;
else
Rf(CA+1) = max(temp);
end

Sign in to comment.

More Answers (0)

Products

Release

R2020b

Community Treasure Hunt

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

Start Hunting!