Error : The following error occurred converting from sym to double

조회 수: 4 (최근 30일)
Raj Arora
Raj Arora 2021년 9월 22일
댓글: Raj Arora 2021년 9월 22일
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
Image Analyst
Image Analyst 2021년 9월 22일
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 2021년 9월 22일
Yes actually this symbolic is needed. I have to use it further in my code

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by