Convert a cell data into variable name
Show older comments
Hi everyone, I have a problem related to the excel data opening in Matlab. I have a document in excell, in which I have a list of parameters with te name of the parameters, their unit, their numerical value and their description. Since I want this parameters in matlab, I import the data from excel to matlab (I have no problem with that). I use the following command:
[a,b]=xlsread('Parameters_excel');
With that command, I get an 'a' vector with the numerical values of the parameters and a 'b' matrix with all the text of the excell.
a =
1.0e+13 *
0.000000034700000
0.000000000008935
0.000000000540000
0.000000000053412
0.000000000009700
0.000000001240000
0.000000000006300
0.000000000009000
0.000000000012000
0.000000000000940
0.000000000102500
0.000000000000123
b =
'Mplatf' 'kg' '' 'Platform's mass'
'GMplatf' 'm' '' 'Platform's center off mass'
'Jrotor' 'kg*m^2' ''
'Jgen' 'kg*m^2' ''
'Ngbr' '' '' 'Gearbox ratio'
'Arotor' 'm^2' '' 'Rotor's area'
'Rrotor' 'm' '' 'Rotor's radio'
'rt' 'm' '' 'Hub height'
'Zbuoy' 'm' ''
'Dbt' 'm' '' 'Diameter of buoy cilinder'
'ro_w' 'kg/m^3' '' 'Water density'
'ro_a' 'kg/m^3' '' 'Air density'
Now the problem is that I have only parameter's value without the name of them, I mean, instead of Mplatf=347000 I have a(1,1)=347000. What I want is to create variables with the name and value of the parameters.I mean, I would like to have the following variables:
Mplatf=347000, GMplatf=-89.92...
Is there any way to do it automatically?
Accepted Answer
More Answers (1)
You can also use the command
help assignin
But IMO, @Stephen Cobeldick is using a better data structure.
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!