# Matlab help. CSM Radar XPDR Gains

#### n72.75

##### Move slow and break things
Orbiter Contributor
Tutorial Publisher
Donator
So I could use a little help from someone with a copy of Matlab.

The image below is a gain map of the normalized gain of the Apollo CSM Rendezvous Radar Transponder as seen from the LM; it is plotted with respect to the spherical coordinates of the LM's position as seen by the CSM
with $\theta$ on the vertical axis and $\phi$ on the horizontal.

I'm looking to fit it to a polynomial surface of the form (X+Y)^n (with everything X, Y, Z, normalized to a 0--1 range).

Matlab's polyfit() function would be nice, but it's not implemented in GNU Octave. This is probably not the most efficient way to compute gain every timestep, so if there's a lightweight lookup table (bicubic) function that folks have used with Orbiter before I'm interested.

Donator

#### n72.75

##### Move slow and break things
Orbiter Contributor
Tutorial Publisher
Donator
Awe crap.

I ment fit() not polyfit().

#### Thunder Chicken

Donator
Awe crap.

I ment fit() not polyfit().

Will interp1, interp2, or interp3 in Octave do what you need?

#### n72.75

##### Move slow and break things
Orbiter Contributor
Tutorial Publisher
Donator
Will interp1, interp2, or interp3 in Octave do what you need?

interp[1,2, or 3] would be great if I was doing the computations in matlab/Octave rather than in C++

The result I'm looking for would look something like this:

Code:
double LEM_RR::GetCSMGain(double theta, double phi) //returns the gain of the csm RRT system for returned power calculations
{
double gain = 6; //dB

double gain; //dB

gain =
(-0.31211) +
(-2.15239*phi) +
(-8.04079*theta) +
(0.06704*phi*phi) +
(0.54104*phi*theta) +
(0.95966*theta*theta) +
(-7.44E-04*phi*phi*phi) +
(-0.01377*phi*phi*theta) +
(-0.03972*phi*theta*theta) +
(-0.06686*theta*theta*theta) +
(1.82E-06*phi*phi*phi*phi) +
(2.11E-04*phi*phi*phi*theta) +
(6.97E-04*phi*phi*theta*theta) +
(0.00158*phi*theta*theta*theta) +
(0.00288*theta*theta*theta*theta) +
(1.83E-08*phi*phi*phi*phi*phi) +
(-1.80E-06*phi*phi*phi*phi*theta) +
(-8.25E-06*phi*phi*phi*theta*theta) +
(-1.73E-05*phi*phi*theta*theta*theta) +
(-3.81E-05*phi*theta*theta*theta*theta) +
(-7.84E-05*theta*theta*theta*theta*theta) +
(-1.11E-10*phi*phi*phi*phi*phi*phi) +
(7.94E-09*phi*phi*phi*phi*phi*theta) +
(5.98E-08*phi*phi*phi*phi*theta*theta) +
(1.24E-07*phi*phi*phi*theta*theta*theta) +
(2.80E-07*phi*phi*theta*theta*theta*theta) +
(5.42E-07*phi*theta*theta*theta*theta*theta) +
(1.35E-06*theta*theta*theta*theta*theta*theta) +
(1.54E-13*phi*phi*phi*phi*phi*phi*phi) +
(-1.67E-11*phi*phi*phi*phi*phi*phi*theta) +
(-2.17E-10*phi*phi*phi*phi*phi*theta*theta) +
(-6.85E-10*phi*phi*phi*phi*theta*theta*theta) +
(-9.18E-10*phi*phi*phi*theta*theta*theta*theta) +
(-3.03E-09*phi*phi*theta*theta*theta*theta*theta) +
(-4.28E-09*phi*theta*theta*theta*theta*theta*theta) +
(-1.41E-08*theta*theta*theta*theta*theta*theta*theta) +
(1.41E-14*phi*phi*phi*phi*phi*phi*phi*theta) +
(3.36E-13*phi*phi*phi*phi*phi*phi*theta*theta) +
(1.85E-12*phi*phi*phi*phi*phi*theta*theta*theta) +
(3.07E-12*phi*phi*phi*phi*theta*theta*theta*theta) +
(3.68E-12*phi*phi*phi*theta*theta*theta*theta*theta) +
(1.93E-11*phi*phi*theta*theta*theta*theta*theta*theta) +
(1.60E-11*phi*theta*theta*theta*theta*theta*theta*theta) +
(8.21E-11*theta*theta*theta*theta*theta*theta*theta*theta) +
(-1.73E-16*phi*phi*phi*phi*phi*phi*phi*theta*theta) +
(-1.58E-15*phi*phi*phi*phi*phi*phi*theta*theta*theta) +
(-4.62E-15*phi*phi*phi*phi*phi*theta*theta*theta*theta) +
(-5.04E-15*phi*phi*phi*phi*theta*theta*theta*theta*theta) +
(-5.67E-15*phi*phi*phi*theta*theta*theta*theta*theta*theta) +
(-5.46E-14*phi*phi*theta*theta*theta*theta*theta*theta*theta) +
(-1.58E-14*phi*theta*theta*theta*theta*theta*theta*theta*theta) +
(-2.02E-13*theta*theta*theta*theta*theta*theta*theta*theta*theta);

return gain;
}

This feels like an extraordinarily hamfisted way of doing it though.

#### Thunder Chicken

Donator
I guess I'm still unclear on what you are trying to do. Is the gain function how the image you posted was produced? Are you essentially looking to make an interpolation table vs this complicated function?

#### n72.75

##### Move slow and break things
Orbiter Contributor
Tutorial Publisher
Donator
I guess I'm still unclear on what you are trying to do. Is the gain function how the image you posted was produced? Are you essentially looking to make an interpolation table vs this complicated function?

I didn't explain it well. The image is a from the LMA790-3-LM11 Apollo Operations Handbook page 4.6-74 (352 in the PDF)

The function above was something I computed for another unrelated project, a few years ago when I had access to Matlab.

I'm trying to compute a simpler version, f(x,y) = z, probably something like a 4th or 6th order Pascals Triangle regression of the data points in the image.

Last edited:

#### Thunder Chicken

Donator
That contour map levels are very granular - looks like it only has contours at -6, -3, 0, 3, 6. If you had the original data or could identify the values at each contour you could potentially pick off enough points to get a polynomial fit.

#### n72.75

##### Move slow and break things
Orbiter Contributor
Tutorial Publisher
Donator This is the actual data for the whole CSM as spherical coördinates.

I really think am approximation would do. Some day, we can type that all in and interpolate it...

#### Thunder Chicken

Donator This is the actual data for the whole CSM as spherical coördinates.

I really think am approximation would do. Some day, we can type that all in and interpolate it...

To be honest I think the tedium of putting in an interpolation table would probably be the surest way of getting it done vs trying to tweak a 2-D polymap to get the contours right.

Maybe could crowd-source it and divide the effort? Just need to get a few friends and/or some well-trained chimpanzees to type in a sector into a spreadsheet. :lol:

In the interim, you could simply eyeball an average value for each of the 10x10 sectors and use that as your interpolation map. Maybe identify the sectors and use if statements where you can slowly add data and resolution as needed.

Last edited: