Clear Filters
Clear Filters

How to replace the constitutive model of Matlab into the h5 file?

5 views (last 30 days)
I have built a model in MATLAB which has an intrinsic model for calculating stress strain, but I want to replace this constitutive model which is already in MATLAB with an constitutive model which I have trained in python (i.e. an h5 file). In other words, the original matlab model, stress - constitutive model - strain, would become, stress - h5 file - -strain.
Is this feasible?

Answers (1)

Balavignesh
Balavignesh on 10 Nov 2023
Edited: Balavignesh on 17 Nov 2023
Hi Xifan,
As per my understanding, you would like to know if it's feasible to replace a MATLAB model with a constitutive model you trained in Python.
I would suggest you use the 'h5read' MATLAB function to load the necessary data from the h5 file into the MATLAB workspace. After you have loaded the necessary model parameters from the h5 file, you can use these variables in your MATLAB code.
Here is an example code that could help you understand this:
h5disp('example.h5','/g4/lon')
HDF5 example.h5 Dataset 'lon' Size: 36 MaxSize: 36 Datatype: H5T_IEEE_F64LE (double) ChunkSize: [] Filters: none FillValue: 0.000000 Attributes: 'units': 'degrees_east' 'CLASS': 'DIMENSION_SCALE' 'NAME': 'lon'
startLoc = 1;
count = 18;
stride = 2;
subsetData =h5read('example.h5','/g4/lon',startLoc,count,stride);
% Examining the extracted output from the '.h5 file'
whos subsetData
Name Size Bytes Class Attributes subsetData 18x1 144 double
Kindly have a look at the following documentation links to have more information on:
Hope that helps!
Balavignesh

Categories

Find more on Stress and Strain in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!