save a cell to h5 file in matlab

4 vues (au cours des 30 derniers jours)
Georges Murr
Georges Murr le 6 Mai 2021
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

Réponses (0)

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by