If-else statement not working??
Mostrar comentarios más antiguos
Hi,
I am trying to calculate values of Ct before finding axial induction values for a 9x1 array using the following equations:
C_T=(sigma .* ((1-axial_induction).^2) .* ((Cl.*cos(relative_wind))+(Cd.*sin(relative_wind)))) ./ ((sin(relative_wind)).^2);
if C_T<=0.96
axial_induction=1 ./ (1+(4.*F.*(sin(relative_wind).^2)) ./ (sigma.*Cl.*cos(relative_wind)));
else
if C_T>0.96
axial_induction=1 ./ (((4.*F.*cos(relative_wind)) ./ (sigma.*Cl))-1);
end
end
However I am getting a warning which states that the variable CT might be set by a non scalar operator. I am unsure how to perform the if else statement for all entities inside the 9x1 vector? I researched a function call ismember but am unsure how to use it? Could anybody please help with this?
6 comentarios
Jasmine
el 16 de Jul. de 2014
Ct depends on the value of axial_induction and axial_induction depends on the value of Ct, so how can they evaluate? Does axial_induction have an initial value or something?
Kevin
el 16 de Jul. de 2014
Jasmine
el 16 de Jul. de 2014
I think the warning is there because you compare Ct, a vector, to 0.96, a scalar. Are you saying if all values of Ct are <= to 0.96, or do you want that bit of code to execute if any value within Ct is less than 0.96?
Kevin
el 16 de Jul. de 2014
Jasmine
el 16 de Jul. de 2014
So you want the if-statement to execute 9 times for each time Ct is changed? So that it can check each value in Ct against 0.96 and then set axial_induction accordingly? Does this mean that axial_induction should be a vector of length 9 as well?
Kevin
el 16 de Jul. de 2014
Respuestas (0)
Categorías
Más información sobre Simulink en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!