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?

 Réponse acceptée

Walter Roberson
Walter Roberson le 28 Déc 2020

0 votes

The equation involves x^2 so you should expect an even number of solutions not one solution.

2 commentaires

AHAMMED AFZAL
AHAMMED AFZAL le 28 Déc 2020
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

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by