Error : The following error occurred converting from sym to double

4 views (last 30 days)
So I'm running a programme in which there are two symbolic variables and the rest everything is constant, and hu(x,1) is picking up 100 values from a data set at random. When hu(1,1) > 8 is used in 1st iteartion, the code runs and returns LS1(1,1) = 0, but when hu(2,1) < 8 is used in next iteration, the code stops since it is now a symbolic number for LS1(2,1) and returns this error. I'd appreciate it if someone could assist me with this. (mu, SWm, and roww are all constant)
syms hu1 vk
if hu(x,1) > 8
if hu(x,1)> 10
BF(x,1) = ( 2*(0.5*(0.5+0.2)*1.2)*L);
Fd(x,1) = 0.5*Cd(x,1)*(vk^2).*L*s;
else if hu(x,1) < 10
BF(x,1) = (2*(0.5*(0.5+0.2)*(hu1- 3.1))*L);
Fd(x,1) = 0.5*Cd(x,1)*roww*(vk^2).*L*(hu1-hb);
end
end
LS1(x,1) = (Fd(x,1) - (mu*(SWm - BF(x,1))));
else
LS1(x,1) = 0;
Error : The following error occurred converting from sym to double (for LS1(x,1)
This error is popping out in second iteration. How to deal with this?
  2 Comments
Image Analyst
Image Analyst on 22 Sep 2021
Do they need to be symbolic? What if you delete the line
syms hu1 vk
and just assign them (if needed) in advance of your other code where you use them?
Raj Arora
Raj Arora on 22 Sep 2021
Yes actually this symbolic is needed. I have to use it further in my code

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!