开发者

How can I retrieve images from a cell array in a MAT-file?

I have used the following code to get multiple (64) images into a MAT-file:

D = dir('*.wav');

wavcell = cell(1,numel(D));

for i = 1:numel(D)

  wavcell{i} = wavread(D(i).name);

end

However, I now can't retrieve the images from any of the matrices I have in this MAT-file开发者_Go百科. It contains a 64x1 structure array (D), a 1x64 cell array (imcell) and an array with one number in it (64) (i).

I need to be able to access individual images in the cell array for use in a psychtoolbox experiment.

Any help would be GRATEFULLY received!!


The first problem I'm seeing: you're loading WAV files, which are audio files, not image files. You should first try to remedy this situation.

Once you're sure that you're loading the right type of data (i.e. images), you can get the data back out of the MAT-file you create in a number of ways with the LOAD command:

load('your_file.mat');           %# Loads all the variables in the file
%# OR
load('your_file.mat','imcell');  %# Loads just the variable imcell

Now you will have a variable in the local workspace called imcell which will be a cell array of image data. To index the contents of the cell array, you would use curly braces {} like so:

image1 = imcell{1};  %# Place the contents of the first cell into image1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜