
This is what we should see on June 21st, if it’s a perfect sunny day. Next, we need to get the actual data and compare the two. īut before doing that, it might be a good idea to save what we've done in a script. Check the plot-looks reasonable, so there it is: the theoretical maximum production we should get from our solar panels. But that's not what we meant-we want the exponent for each element of the array, so let's use the up arrow to recall that command, then do what the error message says and change the exponent operation to dot-carat. įinally, we just need to multiply the two intensity factors together (and we've learned from the previous error, so we'll use dot-star this time), and multiply by the size of the panels to get the total theoretical energy production. MATLAB works naturally with vectors and matrices, including doing matrix math. So, by default, MATLAB thinks this carat is a matrix exponential. Fortunately, this helpful error message lets us know that we made a common mistake. The more air the light has to get through, the less energy makes it to the panels. To complete the model, we need to calculate the effect of the atmosphere. Okay, that’s the angle of the sun accounted for. But in Massachusetts the sun never gets directly overhead, even in June, so the plot looks about right. The intensity of radiation due to the angle of the sun should be 0 as the sun rises and sets and peak at local noon. And we should get 100% intensity when the sun is directly over the panels.
INTLINPROG FOR MATLAB R2013A HOW TO
And now we also have the code so we know how to do that programmatically next time. We can select the variables t and sunangle, and go to the Plots tab in the toolstrip. But it's probably more informative to view it graphically. If we want to look at the values, we can always double-click on the sunangle variable in the workspace: it opens up the Variable Editor. And let's add a semicolon to the end of the line so the result isn't displayed. Now that we know about cosd, we can complete our formula. Again, this part of the formula is assuming degrees instead of radians, so we could convert or. we could look in the documentation to get more information about trigonometric functions, where we discover that there’s a cosd function that accepts inputs in degrees rather than radians. MATLAB has functions for all sorts of things, from trigonometry to outlier detection to curve fitting to graph theory to signal filtering. So it’s always good to check the documentation.
INTLINPROG FOR MATLAB R2013A CODE
This equation is long, but the MATLAB code looks just like the math, so it's easy enough to implement. That's not exactly the same as the time on the clock, because of conventions like time zones and daylight savings. So, we'll take our vector of times and apply a shift. Īnd now we're ready to calculate the effect of the angle between the sun and the panels. We'll start at 5:30, a little after sunrise, and go in 15-minute increments until 8:00, just before sunset. Let's make a vector to represent time of day. Next, we want to calculate the production throughout the day, so we need a range of times. But we could also use one of the many built-in MATLAB functions. Here we're using the built-in value of pi to do the conversion manually. We can do standard mathematical calculations and assign the result to a new variable or even overwrite the same variable. The angles we've just entered are in degrees, but if we're going to do math with them, it might be better to convert them to radians. Our calculations are entered in the Command Window and executed immediately and we can see the variables we've just created over here in the Workspace. Let's use the value for June 21, the longest day of the year, so that will give us the maximum amount of production. There's a theoretical model that says what the production should be. Let's implement that and compare it with the actual data recorded from the panels. įirst, we need some constants: the latitude of Natick and the “solar declination,” which is just an angle that tells us how high in the sky the sun gets on a given day. These are values we can look up.

See all those nice solar panels? Well, let's see if they're working properly. This is one of the buildings at MathWorks headquarters in Natick, Massachussetts. Be sure to stay to the end to find out where to go next to learn MATLAB in depth.

This video will show you the basics and give you an idea of what working in MATLAB looks like. MATLAB ® is an environment for all kinds of technical computing-like data analysis, simulation, and algorithm development.
