

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. 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.
