Error: Conversion to logical from sym is not possible

3 views (last 30 days)
Hello there. I get the following error for my code: "Conversion to logical from sym is not possible".
I need the if statement due to the root in my equation: if my d gets negativ, it can't solve the equation anymore. that is why i would like to have the following condition that in case of a negativ number it will put d equal to zero.
How can I include if statements in a solver (so having values that are saved as syms)? I need the solver function because the real equation is way more complex but having a root.
Also how can I export the solution to a excel file? I don't understand as the solution is still saved as sym. is there the possibility to convert a sym to a double in the end of the code?
syms x
a = 30
b = 20
c = 10
if d > 0
d = (x-c).*2
else d = 0
end
eqn = a + b - 200.*x - d^0.5 == 0
sol_x = vpasolve(eqn, x)

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!