- Code: Select all

%General Mission Analysis Tool(GMAT) Script

%Created: 2012-07-24 08:48:48

%----------------------------------------

%---------- Arrays, Variables, Strings

%----------------------------------------

Create Array a[2,2] ai[2,2];

Create String newrow;

GMAT newrow = ' ';

GMAT a(1,1) = 2;

GMAT a(1,2) = 4;

GMAT a(2,1) = 5;

GMAT a(2,2) = 6;

Create ReportFile ReportFile1;

GMAT ReportFile1.SolverIterations = Current;

GMAT ReportFile1.UpperLeft = [ -0.0075046904315197 -0.04827586206896552 ];

GMAT ReportFile1.Size = [ 1.0140712945591 1.060344827586207 ];

GMAT ReportFile1.RelativeZOrder = 1312;

GMAT ReportFile1.Filename = 'ReportFile1.txt';

GMAT ReportFile1.Precision = 16;

GMAT ReportFile1.WriteHeaders = On;

GMAT ReportFile1.LeftJustify = On;

GMAT ReportFile1.ZeroFill = Off;

GMAT ReportFile1.ColumnWidth = 20;

GMAT ReportFile1.WriteReport = true;

%----------------------------------------

%---------- Functions

%----------------------------------------

Create MatlabFunction inverse;

GMAT inverse.FunctionPath = 'M:\My Documents\GMAT Sim';

%----------------------------------------

%---------- Mission Sequence

%----------------------------------------

BeginMissionSequence;

Report ReportFile1 a(1,1) a(1,2) a(2,1) a(2,2);

GMAT [ai] = inverse(a);

Report ReportFile1 ai(1,1) ai(1,2) ai(2,1) ai(2,2);

Matlab function

- Code: Select all

function [y] = inverse(x)

y = x^-1;

end

GMAT Results:

- Code: Select all

a(1,1) a(1,2) a(2,1) a(2,2)

2 4 5 6

ai(1,1) ai(1,2) ai(2,1) ai(2,2)

-0.75 0.625 0.5 -0.25

Matlab Result:

- Code: Select all
`K>> a=[2,4;5,6]`

a =

2.00000000000000e+000 4.00000000000000e+000

5.00000000000000e+000 6.00000000000000e+000

K>> a^-1

ans =

-750.000000000000e-003 500.000000000000e-003

625.000000000000e-003 -250.000000000000e-003