79220893

Date: 2024-11-24 19:27:06
Score: 0.5
Natty:
Report link

What about using the fourth dimension?

*if I have wrongly assumed that some parts don't need explaining, please do give feedback!

 fileName = "myDatabase.h5";
 datasetName = "/myDataset";
 myMat1  = zeros(12,24,12,1);
 myMat1ID = 1; % so that you can call the matrix of interest
 myMat2 = ones(12,24,12,1);
 myMat2ID = 2;

 myRandomMatID = 99;

 h5create(fileName,datasetName,[12 24 12 Inf], ChunkSize=[12 24 12 20]);
 % ChunkSize must be given for Inf axes. I picked 20 for a 2MB chunk..
 h5write(fileName,datasetName,myMat1,[1 1 1 myMat1ID],[12 24 12 1]);
 h5write(fileName,datasetName,myMat2,[1 1 1 myMat2ID],[12 24 12 1]);
    
 % We write a random matrix for demonstration
 
 h5write(fileName,datasetName,rand(12,24,12,1),[1 1 1 myRandomMatID],[12 24 12 1]);

 % Matrix 1 size and a 3x3 sample:
 
 mat1=h5read(fileName,datasetName,[1 1 1 myMat1ID],[12 24 12 1]);
 disp(size(mat1));
 disp(mat1(1:3,1:3,4));
     
 % The random matrix size and a 3x3 sample:
 
 mat3=h5read(fileName,datasetName,[1 1 1 myRandomMatID],[12 24 12 1]);
 disp(size(mat3));
 disp((mat3(1:3,1:3,8)));
 

Output:

        12    24    12

        0     0     0
        0     0     0
        0     0     0

    
        12    24    12
            
        0.0021    0.8974    0.2568
        0.5009    0.4895    0.9892
        0.8742    0.2310    0.8078
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): What
  • Low reputation (1):
Posted by: Manohar Nayak