Professional Documents
Culture Documents
Tukaew
ECE
2010
Mailbox:
500
MATLAB PROBLEM 4
th
ECE2010 B14
Panyawat
Tukaew
ECE
2010
Mailbox:
500
Your task:
1. Create an empty MATLAB script, copy and paste the above text over there. Save the
script. Give your own script name. Note that all comments are marked green.
2. Run the script. You will see error message(s).
3. Find and fix all bugs in the above script. Remember: all programming errors are
reported
in
red
in
MATLAB
Command
Window.
Example:
You could click on the error message; it will bring you to the line with an error.
You may also want to use Fig. 1 and double check the number(s) used in the initial
script. Note that 1kWh/m2/day = 10001/24 W/m2= 41.67 W/m2. The state of New
Mexico has about 6.5kWh/m2/day.
4. Properly label axes, insert the grid, and insert the title. The x-axis should be Solar
panel efficiency percentage, E; the y-axis should be the Width of the square
area in miles, W.
5. Include the corrected MATLAB script, and the corresponding contour plot into your
MATLAB report.
Fig. A1. A map of average daily solar radiation from National Renewable Energy Laboratory, U.S.
Panyawat
Tukaew
ECE
2010
Mailbox:
500
Questions
clear all;
close all;
%-------------------------------------------------------% Vector of available area widths (a 1D array of numbers)
Wmiles = [1:1:150]; % width of the square area in miles (vector or 1D array)
Wmeters = Wmiles*1609; % width of the square area in meters (vector or 1D array)
A = Wmeters.*Wmeters; % area in m^2 (vector or 1D array); note element-by-element
% vector multiplication!
%-------------------------------------------------------% Vector of available array efficiencies (a 1D array of numbers)
E = [1:1:20]; % efficiency percentage (vector or 1D array)
%-------------------------------------------------------% Matrix of all available total output powers of the array (a 2D array of numbers)
p = 4000; % average daily solar radiation in W per m^2 (scalar)
for i = 1:length(A) % index i corresponds to different areas A
for j = 1:length(E) % index j corresponds to different efficiencies E
P(i,j) = p*A(i)*E(j)*0.01; %total average daily power (2D matrix)
end
end
%-------------------------------------------------------% "Plot" the matrix - a contour plot of all available total output powers
v = [2 10 50 100 300 500 1000]; % create contour plot levels in GWatts
C = contourf(P*1e-9, v); % create contour plot of output powers in GWatts
colormap(summer);
3
Panyawat
Tukaew
ECE
2010
Mailbox:
500
clabel(C, 'FontSize', 11, 'Color', 'r'); % be fancy (do not have to)
grid on; xlabel('Solar panel efficiency percentage, E'); ylabel('Width of the square area in
miles, W'); title('Area vs. Efficiency Graph');
1. What is the size of array A? To answer this question type size(A) in MATLAB
Command Window and hit ENTER.
a. Array A is 1 by 15
2. What is the size of array E?
a. Array E is 1 by 20
3. What is the size of array P?
a. Array P is 150 by 20
4. What happens if you replace two nested for loops by one short line of the code:
P = p*kron(A', E)*0.01;
Here, the prime symbol denotes the transpose operation, i.e. the conversion from a
row to a column; kron stands for a tensor product of two vectors (studied in math
classes), which gives us a matrix.
Does your result change?
No, the result doesnt change.
5. Based on your contour plot please answer the following question: what is the
minimum possible square area (and its width in miles) that gives us the average
electric output of the array greater than or equal to the current USA electric
consumption of 51011 W=500 Gigawatts at the solar panel efficiency of 15%?
25 square miles. 5 miles by 5 miles.
Your report should include:
A.
B.
C.
D.