Help using loop and range interval
Mostrar comentarios más antiguos
I have a wind speed data (v) as a column vector that varies at different instant, I want to create a model = 0.5*1.29*9.62*jan.^3*cp; that uses different coefficient (cp) at a particular range of wind speed v. If v is less than 3, cp = 0, if v falls in a range between 3 and 10 (inclusive) then cp = 0.4, if v falls in a range greater than 10 and less or equal to 14 cp = 0.2 and if v is greater than 14 but less than 25 cp = 0.1 and if v is greater than 25 cp = 0.001. I want to create this model and have a final result of column vector that I will plot. Below is a loop that I tried to write.This is my first time trying to create a loop and also first time trying to have a range interval in matlab code. When I run this code I get an error message "Operands to the and && operators must be convertible to logical scalar values." Please I need help as I don't know how to solve this error. Thanks
jan = airport_spd;
model = 1.29*9.62*jan.^3*cp;
for v = jan
if v < 3
cp= 0;
model = 0.5*1.29*9.62*v.^3*cp;
elseif v >=3 & v<=10
cp = 0.4;
model = 0.5*1.29*9.62*v.^3*cp;
elseif v > 10 && v<= 14
cp = 0.2;
model = 0.5*1.29*9.62*v.^3*cp;
elseif v >14 && v < 25
cp = 0.1;
model = 0.5*1.29*9.62*v.^3*cp;
elseif v > 25
cp = 0.001;
model = 0.5*1.29*9.62*v.^3*cp;
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming 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!