Code covered by the BSD License  

Highlights from
Example files for "Programming with MATLAB" Webinar

image thumbnail

Example files for "Programming with MATLAB" Webinar

by

 

Example files for "Programming with MATLAB" Webinar, first delivered October 3, 2013.

Automated Wind Turbine Data Analysis

Automated Wind Turbine Data Analysis

Analyzes wind data (from multiple locations) stored in a directory to see if the locations are good prospect for a wind turbine.

Contents

Get List of Files in Directory

First, we get the list of files from the data directory.

clear

dirname = 'WindDataFiles';
files = dir(fullfile(dirname, '*.txt'));

fprintf('Files to process:\n');
fprintf('   %s\n', files.name)
Files to process:
   TowerLocation1.txt
   TowerLocation2.txt
   TowerLocation3.txt
   TowerLocation4.txt
   TowerLocation5.txt
   TowerLocation6.txt

Run Wind Data Analysis

Then, we loop through each file and perform the analysis, storing the results into a structure.

% Pre-allocate results structure
winddata(length(files)) = struct('date', [], 'temp', [], 'vavg', [], ...
  'avgPower', [], 'cf', [], 'filename', []);

for ii = 1:length(files)
  % Get filename
  filename = fullfile(dirname, files(ii).name);

  % Display filename
  fprintf('\nAnalyzing %s. \n', filename);

  % Generate and save results
  winddata(ii) = WindAnalysisFcn(filename);

  snapnow;   % used for publishing
end
Analyzing WindDataFiles\TowerLocation1.txt. 
Assumed wind turbine rated power (MW): 1
Averaged turbine power (kW): 194.5258
Capacity factor (%): 19.4526
Analyzing WindDataFiles\TowerLocation2.txt. 
Assumed wind turbine rated power (MW): 1
Averaged turbine power (kW): 248.3086
Capacity factor (%): 24.8309
Analyzing WindDataFiles\TowerLocation3.txt. 
Assumed wind turbine rated power (MW): 1
Averaged turbine power (kW): 282.5063
Capacity factor (%): 28.2506
Analyzing WindDataFiles\TowerLocation4.txt. 
Assumed wind turbine rated power (MW): 1
Averaged turbine power (kW): 315.7573
Capacity factor (%): 31.5757
Analyzing WindDataFiles\TowerLocation5.txt. 
Assumed wind turbine rated power (MW): 1
Averaged turbine power (kW): 168.6016
Capacity factor (%): 16.8602
Analyzing WindDataFiles\TowerLocation6.txt. 
Assumed wind turbine rated power (MW): 1
Averaged turbine power (kW): 275.0511
Capacity factor (%): 27.5051

Conclusion

Based on the analysis, we can determine which site has the highest capacity factor.

% Determine the location with highest capacity factor
figure;
bar(100*[winddata.cf], 'FaceColor', [.25 .25 1], 'EdgeColor', 'none');
set(gca, 'YGrid', 'on');
xlabel('Tower Location');
ylabel('Capacity Factor (%)');
[maxCF, maxIDX] = max([winddata.cf]);
[~, loc] = fileparts(winddata(maxIDX).filename);
hold on;

% Mark the best location with a red color
bar(maxIDX, 100*maxCF, 'FaceColor', [1 .25 .25], 'EdgeColor', 'none');
text(maxIDX, maxCF*100, 'Best Location', ...
  'HorizontalAlignment', 'center', 'VerticalAlignment', 'Bottom');

% Output result to screen
fprintf('\n%s had the highest capacity factor of %0.2f%%\n', loc, ...
  winddata(maxIDX).cf * 100);
fprintf('  Average power: %0.2f kW\n', winddata(maxIDX).avgPower/1e3);
TowerLocation4 had the highest capacity factor of 31.58%
  Average power: 315.76 kW

Save Output to MAT-File

Save the results for later use.

save('windataAnalysis', 'winddata')

Contact us