matlab - Allocating matrix / structure data instead of string name to variable -


i have script opens folder , processing on data present. say, there's file "xyz.tif".

inside tif file, there 2 groups of datasets, show in workspace as

data.ch1exyz 

and

data.ch3exyz 

if want continue 2nd set, can use a=data.ch3exyz

however, xyz longer , varies per file, whereas data.ch3e consistent.

therefore tried a=strcat('data.ch3e','origfilename'); origfilename of course xyz, has (automatically) been extracted before.

however, gives me string (since practically typed

a='data.ch3exyz' 

instead of matrix data.ch3exyz is. think it's problem ()'s, []'s, or {}'s ican't seem figure out.

thanks in advance!

if know string, dynamic field references should here , far better eval

slightly modified example linked blog post:

fldnm = 'fred'; s.fred = 18; y = s.(fldnm) 

returns:

y =      18 

so case:

test = data.(['ch3e' origfilename]); 

should sufficient

edit: link the documentation


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -