save a cell to h5 file in matlab
8 次查看(过去 30 天)
显示 更早的评论
How can I save a 1x2000 cells with each cell is a 21x512 matrix into a h5 file in matlab ? It saves all the cells as 1x2000 double and all of them are zeros. I want to save the cells in h5 file to use it in python, if there is another way to do it please let me know, appreciate your help.
for i = 1:length(idxtrain)
x_train{i} = img_array_prec{idxtrain(i)}(:,:,1);
end
%%
for i = 1:length(idxtest)
x_test{i} = img_array_prec{idxtest(i)}(:,:,1);
end
%%
savefileh5 = 'traintest.h5'
%%
try
h5create(savefileh5,'/train/x_train',[size(x_train,1) size(x_train,2)]);
h5write(savefileh5,'/train/x_train',x_train);
catch ME
warning('File already in folder');
end
%%
x_train1 = h5read(savefileh5,'/train/x_train'); %it gives double
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Python from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!