Skip to main content
1-Visitor
October 6, 2010
Solved

How to find maximum for 2 variable function

  • October 6, 2010
  • 3 replies
  • 15490 views

My elevation function depends of day of year (d) and decimal hours of the day(hrs)

I want to find Solar Noon the point of highest elevation angle.

I have done it for just one day of the year. But i want it to be able to calculate solar noon for any day of the year. I want it to be a variable of d as well

Attaching the image for help

Thank you in advance you guys have really helped a lot in there.

Best answer by f.kohlhepp

You've been yelled at for not posting the sheet; we're all lazy and hate typing.

In the image you posted there's a solve block. Above the given (under the X in the image) you define a guess variable, and the condition in the solve block has an argument with two parameters, "Today" and "hrs." I'm assuming from the output of the solve block that hrs is the guess variable. Rewrite the "Find" statement to be:

LocalSolarNoon(Today):=Find(hrs)

Now your solve block is a function. When you write "LocalSolarNoon(xxx) =" it will compute the solve block for watever value you've put in for xxx.

3 replies

12-Amethyst
October 7, 2010

Minimizing for two variables is always a hard task. For the nature of your problem probably the best approach could be eval z=f(x,y) over a rectangular grid (x,y) and search for min in the matrix z.

What you can do with partial derivatives is search the critical points, but numerically they are that, points, when the analysis shows that they usually are spatial lines with some isolated points too.

Regards. Alvaro.

1-Visitor
October 7, 2010

how can i reduce the dimensionality

A(1,hrs) to B1(hrs)

A(2.hrs) to B2(hrs)

then i only want to find the maximum of B1(hrs) and B2(hrs) to B365(hrs) save all that in an array

12-Amethyst
October 7, 2010

Discretize (this is the usual matlab method):

n.day = 1

n.hrs = 199

n.r = 0..n.day

n.c = 0..n.hrs

This is: a grid 2x200

days[n.r = n.r[n.r

hrs[n.c = n.c[n.c

M[n.r,n.c = A(days[n.r , hrs[n.c)

Now you have a matrix of values in the grid. Can search for max or min with ... max and min functions, and can take where the max or min occurs with match.

Regards. Alvaro.

1-Visitor
October 7, 2010

Posting the actual sheet would be much more useful if you really want help. Not that many people have the patience to re-type portions of a sheet, with unknown numbers of missing parameters.

But, in your particular case, your assignment of UTCSolarNoon to the find(hrs) should be made into a function ala UTCSolarNoon(day):=find(hrs). You then create a vector of days of the year and feed it to the function, and get back a vector solar noons.

TTFN

1-Visitor
October 7, 2010

Posting the actual sheet would be much more useful if you really want help. Not that many people have the patience to re-type portions of a sheet, with unknown numbers of missing parameters.

We seem to say this all the time.

In my personnel experience, I feel more willing to help when a worksheet is included.

Mike

1-Visitor
October 7, 2010

then you are doing the work for me.

I guess you guys don't mind that. so here is the worksheet. scroll 3/4 way down till you reach the yellow box. I have explained what i want to do

Thanks in advance.

1-Visitor
October 7, 2010

You've been yelled at for not posting the sheet; we're all lazy and hate typing.

In the image you posted there's a solve block. Above the given (under the X in the image) you define a guess variable, and the condition in the solve block has an argument with two parameters, "Today" and "hrs." I'm assuming from the output of the solve block that hrs is the guess variable. Rewrite the "Find" statement to be:

LocalSolarNoon(Today):=Find(hrs)

Now your solve block is a function. When you write "LocalSolarNoon(xxx) =" it will compute the solve block for watever value you've put in for xxx.

1-Visitor
October 7, 2010

thats it.

it works.

I guess i over complicated the problem myself.

1-Visitor
October 7, 2010

There seems to be an issue with your worksheet when opening in M14, see attached image.

Also, your equation goes red when I get down to the hrs.min(d) function - You seem to be calling UTLSolarNoon as a function without making the solve block a function.

Mike