Matlab: Using detrend(var) but using the variable referenced in the string saved in 'var' -


my code loads in .mat file number of data arrays in it. user names arrays in file want, tell code variable names through gui, saves array names string in variable.

i need perform detrend() on these arrays before plotting them, detrend function references variable name rather array.

example: ... varname = get(handles.edit1,'string') ; %'data1' ... load (file.mat) %contains data arrays

data = detrend(double(varname)); ...

instead of load('file.mat') pollutes code's namespace user data, use

userdata = load('file.mat'); 

or even

userdata = load('file.mat', varname); 

after this, can do

userdata.(varname) 

to access variable name in string varname, contents read file file.mat.

you use fieldnames(userdata) find out array names, instead of requiring user remember , type them in.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -