|
Hi,
I have an Excel worksheet (extension *.xls) that contains data. The first row are column headers with text, and all following rows are numerical.
The column headers had such names as "P," "P_Sat," "T," "T_Sat," etc., so they were simple strings with no spaces or special characters.
I used MATLAB to import the Excel file and asked it to "Create vectors from each column using column names." I also checked the option to generate the m-function that could repeat the import action.
This worked flawlessly, and I got MATLAB variables containing an array of the data corresponding to the same column names and numerical data from the Excel worksheet.
Now, I want to assign these variables into structures by editing the auto-generated m-file from the import function. Using the same example column header names as listed above, I'd like it to produce, in the MATLAB workspace:
Import.Tank.Hydrogen.P
Import.Tank.Hydrogen.P_Sat
Import.Tank.Hydrogen.T
Import.Tank.Hydrogen.T_Sat
etc....
so that all the data are assigned into structures.
I tried doing that by editing the auto-generated import m-file by modifying the 2nd to last line:
FROM:
assignin('base', vars{i}, dataByColumn1.(vars{i}))
TO:
assignin('base', ['Import.Tank.Hydrogen.' vars{i}], dataByColumn1.(vars{i}))
But it gave me an error: "Invalid variable name "somevar.hoodle.hi" in ASSIGNIN."
Seeing that the command "ASSIGNIN" can't be used to assign values into structures, only arrays, is there an equivalent command for structures?
|