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?

 Risposta accettata

Walter Roberson
Walter Roberson il 28 Dic 2020

0 voti

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

2 Commenti

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

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by