% ECE 111 Lecture #4 % Computer the power curve for a 2500kW wind turbine function [kW] = PowerCurve( Wind ) x = [0,1,2,3,4,5,6]'; y = [0,100,200,600,1500,2500,2800]'; B = [x.^3, x.^2, x]; A = inv(B'*B)*B'*y; kW = 0*Wind; for i=1:length(Wind) if(Wind(i) > 6) kW(i) = 2800; else x = Wind(i); kW(i) = [x^3, x^2, x] * A; end kW(i) = min(kW(i), 2800); kW(i) = max(kW(i), 0); end end