How do I assign a complex value into a non-complex location?

I have the following code that will calculate the rotation of a motor based upon an input flux and temperature. The function is being run in Simulink, but I keep getting the error "Cannot assign a complex value into a non-complex location" at the last line in the function (that actually calculates Theta). I can see that theta may be complex due to the feedback loop that was built around the temperature T, but I don't see how to solve it. I have attached a picture of the simulink model as well.
Thanks,
Greg
function Theta = flow_rate(Q,T)
%Calc theta position
Theta=complex(0);
Ti=600; %constant inlet particle temperature (degree C)
%Convert the output of the servo motor (theta) to linear distance, assumes
%3000 counts per turn
slot_length=1.16;% m
%Heat Transfer Model
Cp=1200; %specific heat of the particles
%beverloo Constants and parameters
C1=19;
C2=8.9;
rho_b=2000; %bulk density, kg/m^3
d_p=0.35e-3;%particle diameter, 350 micron
g=9.81; %gravity
Theta=((Q/(C1*rho_b*sqrt(g)*slot_length*Cp*(T-Ti)))^(2/3)+C2*d_p)*3000;

4 Comments

Did you get any solution to this problem?
Even I am looking for the answer to this question.
For function inputs Q and T, there are going to be problems when Q and (T-Ti) are of opposite sign. Is there any explicit or implied way to prevent this, prior to the function call?

Sign in to comment.

Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Asked:

on 6 Dec 2017

Commented:

on 17 Aug 2020

Community Treasure Hunt

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

Start Hunting!