matlab-load

How to load .mat file which has a variable filename?

强颜欢笑 提交于 2019-12-02 07:51:10
问题 %select all .mat files oar = dir('*oar.mat'); n = {oar.name}; %loop through files for l=1:length(oar); load pat_oar(l) %<---this is the .mat file with variable filename clear ... end How do I write some Matlab script that will read in one .mat file after another... 回答1: You file names are stored in n , so you should be able to do: for l=1:length(oar) load(n{l}) end 回答2: Use the functional form. Instead of: load pat_oar{I} Use load(pat_oar{I}) Calling a Matlab command using the unix-style

Load Multiple .mat Files to Matlab workspace

狂风中的少年 提交于 2019-11-29 12:05:44
I'm trying to load several .mat files to the workspace. However, they seem to overwrite each other. Instead, I want them to append. I am aware that I can do something like: S=load(file1) R=load(file2) etc. and then append the variables manually. But there's a ton of variables, and making an append statement for each one is extremely undesirable (though possible as a last resort). Is there some way for me to load .mat files to the workspace (by using the load() command without assignment) and have them append? Its not entirely clear what you mean by "append" but here's a way to get the data

How can I move variables into and out of a structure akin to LOAD and SAVE in MATLAB?

╄→гoц情女王★ 提交于 2019-11-29 09:56:25
Is there a quick way (i.e. one line) to dump a collection of variables "in" a structure, using the variable names as the structure fields? The "load" function basically does this but saving and loading to a temporary file seems ugly. For example: clear a = 'adsf' b = rand(10); x = var2struct(a,b) x.a x.b or better yet: x = var2struct(['a';'b']) Also, what about the reverse (i.e. dumping the field values to the current scope as variables named after the fields)?: clear x.a='asdf' x.b=rand(10); dumpstruct(x) a b Also, here's a related newsgroup thread . Aside from using LOAD and SAVE , there is

Load Multiple .mat Files to Matlab workspace

你。 提交于 2019-11-28 05:34:25
问题 I'm trying to load several .mat files to the workspace. However, they seem to overwrite each other. Instead, I want them to append. I am aware that I can do something like: S=load(file1) R=load(file2) etc. and then append the variables manually. But there's a ton of variables, and making an append statement for each one is extremely undesirable (though possible as a last resort). Is there some way for me to load .mat files to the workspace (by using the load() command without assignment) and

How can I move variables into and out of a structure akin to LOAD and SAVE in MATLAB?

纵然是瞬间 提交于 2019-11-28 03:14:05
问题 Is there a quick way (i.e. one line) to dump a collection of variables "in" a structure, using the variable names as the structure fields? The "load" function basically does this but saving and loading to a temporary file seems ugly. For example: clear a = 'adsf' b = rand(10); x = var2struct(a,b) x.a x.b or better yet: x = var2struct(['a';'b']) Also, what about the reverse (i.e. dumping the field values to the current scope as variables named after the fields)?: clear x.a='asdf' x.b=rand(10);

How can I load 100 files with similar names and/or string in just one step in MATLAB?

為{幸葍}努か 提交于 2019-11-26 04:56:15
问题 I have 100 ASCII files in my directory all named as follows: int_001.ASC int_002.ASC int_003.ASC . . . int_099.ASC int_100.ASC I have to import them in MATLAB all with importdata, which should work as follows: A = importdata(\'int_001.ASC\', \' \', 9) x = A.data(:,1) y = A.data(:,2) My question is: how can I avoid writing 100 times importdata ? Is there a way to write the first string only and then have all data uploaded? Thanks 回答1: fls = dir( 'int_*.ASC' ); for fi=1:numel(fls) A{fi} =