Hello all.(adsbygoogle = window.adsbygoogle || []).push({});

I am having troubles reading in data(from a .hdf file) and giving it my own variable names. I have created a character array var_names with the names I wish to use. The .hdf variables are 3D and 4D (they are climate parameters). What I am trying to do is loop through the variables in the .hdf file and assign them my desired name in Matlab. At the end, I realize that the var_name(a,:) = ...... is trying to put a multi-D array into the 2D var_name variable. This is not what I want, I want the var_name(a,:) to provide the variable name that the .hdf data corresponds to and accept the multi-D .hdf array. If you are not familiar with .hdf format, not to worry, the problem isn't with reading the data in, but storing it in the correct variable name. Thanks for the help!

var_names = char('sea_p', 'sfc_p', 'sfc_geop', 'geop_h', 'o3_mix', 'sp_hum', 'cld_l_mix', 'cld_i_mix', 'rel_hum', 'temp', 'u', 'v', 'pot_vort', 'omega', 'long', 'lat', 'height', 'time');

for a = 0:17

data_id = hdfsd('select', file_id, a);

[name, num_dim, dim_vect, data_type, num_attr_data, status] = hdfsd('getinfo', data_id);

start_vect = zeros(size(dim_vect));

end_vect = dim_vect;

step = [];

var_names(a,:) = hdfsd('readdata', data_id, start_vect, step, end_vect);

end

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB char array with variable names

Loading...

Similar Threads for MATLAB char array |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB Matlab-like software |

MATLAB Matlab data into bins |

**Physics Forums | Science Articles, Homework Help, Discussion**