Hello Matlab community! I'm a begginer at Matlab, and I was given a project to complete. There's a few more steps to it, but right now I'm a little stuck on one particular part. I'm trying to read variables and their values from an easily readable csv file. It needs to be easy to read and change because people will be changing the values. This is what the csv file contains:

Orbital Input Variables, Values, Units

Altitude, 841, km

OrbitalType, 0,

DesiredStaticGSD, 500,

ForwardMotionCompensationFactor, 1,

DetectorSpatialChannels, 2800,

FNumberTelescope, 1, #

RadiusEarth, 6378100, m

I will be using other similar csv files in my code. The code that I have right now is this:

But I find this code a bit confusing and circular. Is there any easier way to do the same thing in an easier code? Or something more direct?

I'm also trying to take the variables imported from the csv file and assign the values of those variables to other variables in a different code I have, so that I can use them in some calculations. Are there any specific ways to do this or any suggestions for how I would go about that?

An alternate way to do something similar altho the units field compounds the effort is to make the file in the form that it could be executed as an m-file (or the text read and interpreted) by writing the data lines as valid Matlab assignments. This does require more discipline upon the user to ensure the line is indeed valid code which may be too much to expect/demand.

As far as passing data to other routines, use argument lists and functions to pass the data -- then the calling routine can use whatever names it has independent of the called function as far as actual name; just have to have a defined interface for the routine/function.

I'm not sure I quite understand. To pass the data to other routines, would I need to enter all this into the command line? I'd be assigning the data value to other variables I have already coded. Excuse my confusion, I'm not great at this stuff.

It's hard to say without know what you'll be doing with the data, but I'd reccomend using the table directly unless you need a different container. Most importantly, you should avoid looping over the rows.