# Export matrix to matlab

**URL:** <https://community.freefem.org/t/export-matrix-to-matlab/136>\
**Category:** General Discussion\
**Created:** [September 10, 2019, 5:38am UTC](https://community.freefem.org/t/export-matrix-to-matlab/136 "2019-09-10T05:38:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanzant](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@vanzant](https://community.freefem.org/u/vanzant)\
**Post date:** [September 10, 2019, 5:38am UTC](https://community.freefem.org/t/export-matrix-to-matlab/136/1 "2019-09-10T05:38:03Z")

</div>

Dear all,

from versions 4.x of FreeFem, the default format for exporting sparse matrices has changed from Morse to Hash.  
Is there anyway to force FreeFem to save the sparse matrices in Morse format?  
Or is there any matlab code, like FFmatrix\_fread, to read hash matrices in Matlab?

Thank you for your attention,

Tom

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [March 12, 2020, 5:54pm UTC](https://community.freefem.org/t/export-matrix-to-matlab/136/2 "2020-03-12T17:54:48Z")

</div>

see example tutorial/sparse-matrix.edp

pass the matrix in CSR format before to write

tutorial/sparse-matrix.edp: MM.CSR;  
tutorial/sparse-matrix.edp: cout \<\< " MM (format CSR or Morse) "\<\< MM \<\< endl;

---

<div class="post-metadata">

**Author:** ![RdMl](https://avatars.discourse-cdn.com/v4/letter/r/a88e57/32.png) [@RdMl](https://community.freefem.org/u/RdMl)\
**Post date:** [March 9, 2026, 3:13pm UTC](https://community.freefem.org/t/export-matrix-to-matlab/136/3 "2026-03-09T15:13:18Z")

</div>

Bonjour à tous ceux qui liront,

Ci-joint un code matlab (FF\_matrix\_fread.m) qui permet d’importer dans la classe SPARSE de matlab des matrices construites par FF++. Les formats FF++ pris en compte sont Morse (CSR), HashMatrix (COO) et Matrix\_Market.

Un script de validation également joint. Il faudra générer ses propres matrices.

Ce script de validation contient aussi un méthode matlab très légère (mais sans aucun contrôle et pas boite noire) d’importation dans matlab. Cette seconde méthode nécessite les commandes cat et grep.

Je vous remercie.

[FF\_matrix\_fread\_src\_et\_valid.zip](https://community.freefem.org/uploads/short-url/48ip1V1w1FL188Cy21oMUXz7YFc.zip) (7.2 KB)
