export the results of feedforwardnet to Fortran?

7 views (last 30 days)
mary
mary on 8 Feb 2023
Answered: Raghav on 10 Mar 2023
I would like to know if it is possible to export a net constructed based on feedforwardnet into Fortran.
Thanks in advcane

Answers (1)

Raghav
Raghav on 10 Mar 2023
Hi,
Based on the question, it can be understand that you want to export feedforwardnet result from MATLAB to FORTRAN.
To export the results of a feedforward neural network from MATLAB to Fortran, you need to first obtain the network output in MATLAB and then export it to a format that can be read by Fortran. Here's a general approach you can follow:
  1. Load the input data into MATLAB and normalize it, if necessary, to match the input scaling used in the network training.
  2. Load the trained network into MATLAB using the load command or by creating a new network object and setting its properties to match the trained network.
  3. Use the MATLAB function sim to obtain the network output for the input data. The output will be a MATLAB array.
  4. Convert the MATLAB output array to a format that can be read by Fortran. One way to do this is to save the array as a CSV file using the MATLAB function writematrix and then read the CSV file in Fortran using a file input/output routine. Another way is to use the MATLAB function fwrite to write the array directly to a binary file, and then read the binary file in Fortran using a file input/output routine.
In Fortran, you can then use the network output as needed in your code.
It's important to note that the output format used in step 4 should match the expected input format in Fortran, so you may need to modify the format depending on the specific requirements of your application. Additionally, you may need to convert the output from MATLAB's default floating-point format to a format that is compatible with your Fortran code, such as single or double precision.
You can also refer to the below mentioned documentation to know more about the working of Fortran & MATLAB:
Hope it help!
Regards,
Raghav Bansal

Categories

Find more on Fortran with MATLAB 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!