If you take a look at the GPL v2 and proprietary extensions question you can get to the conclusion that if the proprietary software you depend on to create a script does not allow to do so(license modules/scripts/extensions as GPL or other open license), you will not be able to make your script free form the start.
The holder of the software patents/rights can on its EULA enforce how a derivate plugin/script/customization can behave and what license is imposed.
But, if your software provide does not states clear to forbid scripts to be free, this is exactly the same thing that happened with the Java Trap:
April 12, 2004
If your program is free software, it is basically ethical—but there is
a trap you must be on guard for. Your program, though in itself free,
may be restricted by nonfree software that it depends on. Since the
problem is most prominent today for Java programs, we call it the Java
A program is free software if its users have certain crucial freedoms.
Roughly speaking, they are: the freedom to run the program, the
freedom to study and change the source, the freedom to redistribute
the source and binaries, and the freedom to publish improved versions.
(See http://www.gnu.org/philosophy/free-sw.html.) Whether any given
program in source form is free software depends solely on the meaning
of its license.
Sun continues to develop additional “standard” Java libraries, and
nearly all of them are nonfree; in many cases, even a library's
specification is a trade secret, and Sun's latest license for these
specifications prohibits release of anything less than a full
implementation of the specification. (See
Sometime ago, a lot of features from Java were not free, creating this trap where even if you have developed a GPL software with Java, you will still be bound to restrictions of the software infrastructure required(that is nonfree).
Making a comparsion with this Java specific case, best thing you can do is also find a good opensource implementation that could replace Matlab and also make use of your scripts. But this is just an advice and there is no much that can be done if your software requires nonfree software to be able to run.
Have you ever tried GNU/Octave? Maybe it can be a good alternative for drop-in compatible with many Matlab scripts as their site advices, and you could also help the development team by reporting issues you could face.
Short answer: It depends if the software rights holder specifies if this extension/script can be created on opensource license. Even if this company/person does not deny you from creating free software scripts that depends on this proprietary software, you will still be in a trap because they can change this terms whenever they want.