I have written a code to read from a csv file, write ariables to variable names, and use those variables in various equations. I have most of the code done, but my equations are giving me an error. I have a csv file that looks like this:
Orbital Input Variables Values Units
Altitude 841 km
OrbitalType 0
RadiusEarth 6378100 m
And I have a readcsv file that looks like:
Orbits = readtable('OrbitalInputs.csv','HeaderLines',0,'ReadVariableNames',true);
mask = ~cellfun(@isempty,Orbits.(1));
OrbitalInputs = cell2struct(num2cell(Orbits{mask,2}),Orbits{mask,1});
OrbitalInputs.Remark = 'These are my imported Orbital variables';
As well as a function to set these values equal to the variables that looks like:
function OrbitalInputs = SetOrbitalInputs()
tOrbit = readtable('orbitalInputs.csv','readRowNames',1);
OrbitalInputs.Altitudekm = tOrbit{'Altitude','Values'};
OrbitalInputs.OrbitalType_ZeroForCircular = tOrbit{'OrbitalType','Values'};
end
And another function that looks like this:
function OrbitalCalc = OrbitalValues(OrbitalInputs)
tOrbit = readtable('orbitalInputs.csv','readRowNames',1);
OrbitalCalc.Altitude.Miles = 0.621371192 .* OrbitalInputs.Altitudekm;
OrbitalCalc.Altitude.NautMile = 0.539956803 * OrbitalInputs.Altitudekm;
OrbitalCalc.Altitude.Meters = 1000 * OrbitalInputs.Altitudekm;
end
But I keep getting an error that says
"Undefined operator '.*' for input arguments of type 'cell'.
Error in OrbitalValues (line 11)
OrbitalCalc.Altitude.Miles = 0.621371192 .* OrbitalInputs.Altitudekm;"
What am I doing wrong?