I am not certain what you have already tried.
Perhaps the edfwrite function in the Signal Processing Toolbox will do what you want. It was introduced in R2021a (the latest release), so it will be necessary to upgrade to R2021a (if you are not already using it) in order to use that and related functions.
Note — I have never used edfwrite, so I will only be able to provide minimal help with it.
