From: Camron Call on 27 May 2010 11:43 That's fine. I can write the code to do it in a loop. So I would really like to know what would be the best way to save the data and preserve it's variable names and hierarchy. How do you make nested structures programatically if I want it to be organized like: Aircraft.Mass.Calibration.Name1 so that I can type --> Aircraft.Mass.Calibration.Name1.value and get the value string or get the units by Aircraft.Mass.Calibration.Name1.units or even have Name1 be a cell array with 4 entries. So as to access it by something like: Aircraft.Mass.Calibration.Name1{1} Would this type of data fit well into a dataset type?
From: TideMan on 27 May 2010 16:09 On May 28, 3:43 am, "Camron Call" <camronc...(a)gmail.cam> wrote: > That's fine. I can write the code to do it in a loop. So I would really like to know what would be the best way to save the data and preserve it's variable names and hierarchy. > > How do you make nested structures programatically if I want it to be organized like: > Aircraft.Mass.Calibration.Name1 > so that I can type --> Aircraft.Mass.Calibration.Name1.value and get the value string or get the units by Aircraft.Mass.Calibration.Name1.units > > or even have Name1 be a cell array with 4 entries. So as to access it by something like: > Aircraft.Mass.Calibration.Name1{1} > > Would this type of data fit well into a dataset type? Yes, but even better, IMHO, is to use an array of structures. There would be 4 fields corresponding to your 4 columns (name, value, units, inout), and each record would be an index in the structure. So, for example, s(5).name would be 'Aircraft.Mass.Certification.Name5' (from your file listing above). and s(5).units would be 'lb'. You can generate this structure in the loop as you read the file in line by line: for id=1:1000 line=fgetl(fid); if line == -1,break,end % -1 means EOF % Parse each line here s(id).name= s(id).value= s(id).units= s(id).inout= end
First
|
Prev
|
Pages: 1 2 Prev: ellipse points regularly spaced, or inverse of the incomplete Next: Energy of signal |