I had to use a different solution since the above solution did not solve the problem for me. I am using Matlab R2021a and Ubuntu 18.
in MATLAB command window produced the follwing error:
cmake: /usr/local/MATLAB/R2021a/bin/glnxa64/libcurl.so.4: version `CURL_OPENSSL_4' not found (required by cmake)
This is what worked for me:
It seems that the installed cmake version for Ubuntu 18 is v1.10, but Matlab needs version v1.15+ for ROS Toolbox.
Remember to add the export lines to your .bashrc
I could then succesfully run:
folderpath = fullfile('~/catkin_ws/src/mavros')
to build mavros_msg