How can I implement nested for loops to return all the possible combinations

1 view (last 30 days)
I have a script that is attached below that models the power output of a wind turbine and PV panel array at hourly intevals. I need to use exhaustive search to find the power output for every combination of turbine radius and number of PV panels. The hourly irradiance and wind speeds are given by 8760x1 column vectors. I have tried to impliment two for loops for return all the power outputs from the possible wind turbine and PV panel size arrays although its not working and i dont know why, although i do know i mustnt be coding it correctly. currently i am getting the following error
Unable to perform assignment because the left and right sides have a different number of elements.
Error in KB7045_HRES_costing (line 29)
Vhub(i) = vref.*log(Hhub(i)/z0)./log(zref/z0); %(m/s)

Answers (1)

David Hill
David Hill on 29 Apr 2021
Your missing a few references. Just form a matrix of all possible combinations using meshgrid. No loops needed.
WT_r = 1:0.5:30; % possible turbine radius'
PV_panels = 1:30; % PV panel ammounts
[r,N_PV]=meshgrid(WT_r,PV-panels);
z0 = 0.03;
vref=;%need
zref=;%need
irrad=;%need
Avg_Temp=;%need
Hhub = 2*r;
rho = 1.225; % (Kgm^-3) density of air
Mum = 0.95; % mechanical efficiency
Mue = 0.95; % electrical efficiency
Aw = pi*r.^2;% (m^2) area of the rotor
Vhub = vref.*log(Hhub(i)/z0)./log(zref/z0); %(m/s)
Cp = (-2.025e-7*Vhub.^6) + (1.926e-5*Vhub.^5) - (7.421e-4*Vhub.^4)...
+ (1.483e-2*Vhub.^3) - (0.162*Vhub.^2) + (0.887*Vhub) - (1.508);
Cp(Cp<0)=0; %replaces all negative Cp values with 0
P_turbine = 0.5 * rho * Mue * Mum * Aw.*Vhub.^3.*Cp;
% ************************** PV panel *********************************
% This section contains the modelling of the PV panel from the HRES
% PV panel parrameters
Y_PV = 275; % PV panel rated power output
R_STC = 1000; % Solar intensity under test conditions
Alpha_P = -0.39; % Temperature coefficient of power output
T_STC = 25; % Temperature under test conditions
% Calculate the hourly power output
Power_Pv = Y_PV*(irrad/R_STC)*(1+Alpha_P*(Avg_Temp-T_STC))*N_PV;

Categories

Find more on Wind Power in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!