Do not worry about MATLAB impacting the security of your Ubuntu installation, with regards to firewalls and public WiFi.
MATLAB will open TCP ports for certain things (esp. to verify the license is valid,) depending on how it is configured and how it is used. Normally, MATLAB does not act as a network server, which is what most basic firewall configurations are concerned with.
Running MATLAB wihtout a firewall is not likely to be a security risk, unless your MATLAB script is accessing sensitive data from a remote location. If you work with sensitive data, and this is your concern... do not use public WiFi. A firewall will not help you in this case.
If you are concerned about your computer being compromised as a result of using MATLAB without a firewall, then you do not need to worry.