My pick this week comes from former guest blogger, Idin Motedayen-Aval. I spend a lot of my time interacting with MATLAB users and showing examples of things you can do with the various MathWorks products. After these mettings, we always like to make the example available to everyone who attended so they can learn from the material. We use FTP for this since the files tend to be large.
I used to use FileZilla for this but since it's the same process, a couple of years ago I automated it with MATLAB using a little utility function called ftplink. Here's the help for it:
% Usage: ftplink(name, file) - returns ftp link and uploads file to it ftplink(name) - returns ftp link ftplink() - returns home directory
This function always worked great from MathWorks headquarters and from my house but not from hotels or many other public wireless networks. I just assumed it was a firewall blocking it until I shared this utility with my colleague, Adam, who pointed out that I was not using passive mode in FTP - something new to me. An explanation is here. He pointed me to Idin's submission and said if I used it, it would work.
I like that Idin has laid out the code and template for how to enter passive mode, but do not like the implementation. He suggests that we overwrite a few of the builtin files for ftp and add new methods to it. Overwriting shipping code is generally a bad idea and should be avoided unless Tech Support tells you to. It also means that with every MATLAB release, you have to repeat these steps with the new MATLAB version. Instead, Adam took his ideas, made a copy of ftp and renamed it customFTP. With customFTP on the path, it will work in any release and we won't be modifying any MATLAB shipping files or doing anything else that could require UAC.
For my ftplink function, I literally had to change a few characters and now it works everywhere:
Thanks Idin and Adam!
要发表评论，请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。