how to store heterogenous objects in matlab?
I need to make an image pyramid in matlab for one of my assignments. Though there are inbuilt methods to get the individual images in the pyramid, I am confused about how to store the handles to the images. (I don't have much experience with matlab)
Arrays don't work, since the images in the pyramid are of different size. I am looking for something like a list in .net, or arraylist in Java. In MATLAB linked list, they say that you can use the standard Java classes, but matlab hung when i tried to use java's arraylist. So, what is the best way to store a collection of heterogeneous data(or handles?) in matlab?
EDIT1 : The code which is not working:
im0 = imread('..\lenna-lg.jpg'); //im0 = 480*480*3 array
im1 = impyramid(im0,'reduce'); //im1 = 240*240*3 array
pyramid 开发者_运维百科= [ im0, im1 ]; //Error : Error using ==> horzcat
//CAT arguments dimensions are not consistent.
So with some further searching, i have found out what is called a cell, which basically seems to be a heterogeneous array. (http://stackoverflow.com/questions/2662964/cell-and-array-in-matlab). So the following code is working now
im0 = imread('..\lenna-lg.jpg'); //im0 = 480*480*3 array
im1 = impyramid(im0,'reduce'); //im1 = 240*240*3 array
cell = [ {im0}, {im1} ]; //cell = 1*2 cell
ans = cell{1}; //ans = 480*480*3 array
This seems to be a very convenient way to handle heterogeneous data. Is this the right way to go about this?
精彩评论