This shows you the differences between two versions of the page.

sep:software:matlab [2008/07/16 17:28] altheyab created |
sep:software:matlab [2015/05/27 02:06] (current) |
||
---|---|---|---|

Line 1: | Line 1: | ||

- | ====== Peculiarities and hints about running Matlab on the SEP computer environment ====== | + | ====== Running Matlab on the SEP computer environment ====== |

- | ===== On what machines Matlab should be run ===== | + | ** On what machines Matlab should be run: ** |

+ | cities and moods. | ||

+ | You are not allowed to run it on vostok because of its gateway functionality. | ||

- | Run it from sthelens, and only if sthelens is down, from cher, orsay or tiree. It works on other machines too, but some of the other machines have older versions of the OS and core dump upon exiting from matlab. Some other local machines with new setups work fine. Try your local machine. Matlab is blocked from running on the servers (koko and okok). | + | \\ |

- | ---- | + | ==== What to do if Matlab won't start ==== |

- | | + | |

- | ===== What to do if Matlab won't start ===== | + | |

There can be three reasons for Matlab not to start: | There can be three reasons for Matlab not to start: | ||

- | - //You are on the wrong machine//, usually koko. See previous tip. | + | - //You are on the wrong machine//, like teslas. |

- | - //Koko has rebooted and the license manager has not been started yet because the autostart script is broken.// If you do not have koko's root password call either the Matlab Administrator or somebody with a root password. If you do have koko's root password, "su", then "su - lomask" . Type: \\ "/linux_local/matlab71/etc/lmdown -glnx86; /linux_local/matlab71/etc/lmstart -glnx86" | + | - //vostok has rebooted and the license manager has not been started yet. The steps to restart license server: 1) Log onto vostok 2) cd /opt/matlab2011b/etc/ 3) run ./lmdown 4) run ./lmstart. If it does not return error msg, it indicates the license manager has been started successfully.// |

- | - //More than 5 users are running Matlab//. This happens about two times a quarter. On any machine, type "ls /usr/local/var/matlab*" to find who is running it. The filenames listed will show when matlab was started, by whom and on what machine. If you //really// need to use Matlab, contact the five current Matlab users, find out who needs Matlab the least that very moment and ask him/her to shut down his/hers Matlab session(s) so that you can use it. Every time all five licenses got used, there was at least a person who simply had Matlab open without actually using it. If a machine running Matlab crashes (the whole machine, not just Matlab), the record of that matlab session will not be deleted from "/usr/local/var". If you see a very old Matlab process record that you are //sure// it is not running any longer (i.e. you checked on that machine with "ps aux|grep matlab"), remove by hand the corresponding file from "/usr/local/var". | + | |

- | - //Some important files in one of the subdirectories of "/net/koko/linux_local/matlab71/" or in "/usr/local/bin" have been altered//. Call the Matlab Administrator to reinstall Matlab. | + | |

- | ---- | + | \\ |

- | ===== Backup machines for Matlab ===== | + | ==== Backup machines for Matlab ==== |

If "koko" is misbehaving and you need Matlab, of if all five licenses are taken and nobody would close their session, or if you need toolboxes we don't have, you can use the university's machines. Here's how. | If "koko" is misbehaving and you need Matlab, of if all five licenses are taken and nobody would close their session, or if you need toolboxes we don't have, you can use the university's machines. Here's how. | ||

Line 42: | Line 40: | ||

You can also use "scp <files_here> <username_there>@<machinename>:<path_to_files_there>", either from the local machine to the remote one, or the other way around. | You can also use "scp <files_here> <username_there>@<machinename>:<path_to_files_there>", either from the local machine to the remote one, or the other way around. | ||

- | ---- | + | \\ |

+ | ==== SEPlib-Matlab I/O Package ==== | ||

- | ===== SEPlib-Matlab I/O Package ===== | + | If you need to read/write SEPlib format files from Matlab when running Matlab outside the SEP computing system, {{:sep:software:toolbox.tar.gz|download}} the I/O toolbox and unarchive it with "tar -xvzf toolbox.tar.gz" or copy it from /usr/local/matlab7/toolbox/nick/. Let the Matlab Administrator know of any bugs, he'll appreciate the feedback. Solving them, or extending the capabilities of the toolbox to handle other OSs than Linux are even more appreciated. |

- | If you need to read/write SEPlib format files from Matlab when running Matlab outside the SEP computing system, [[toolbox.tar.gz|download]] the I/O toolbox and unarchive it with "tar -xvzf toolbox.tar.gz" or copy it from /usr/local/matlab7/toolbox/nick/. Let the Matlab Administrator know of any bugs, he'll appreciate the feedback. Solving them, or extending the capabilities of the toolbox to handle other OSs than Linux are even more appreciated. | ||

- | ---- | ||

- | ===== The main Matlab web help site ===== | + | \\ |

+ | ==== The main Matlab web help site ==== | ||

can be found at [[http://www.mathworks.com/access/helpdesk/help/helpdesk.shtml|www.mathworks.com/access/helpdesk/help/helpdesk.shtml]]. It is much richer than the simple line-of-command help, it has examples, pictures, and tutorials on how to use each of the toolboxes. The search feature is also quite useful, it searches through their pdf documents and through the user-posed questions, too. | can be found at [[http://www.mathworks.com/access/helpdesk/help/helpdesk.shtml|www.mathworks.com/access/helpdesk/help/helpdesk.shtml]]. It is much richer than the simple line-of-command help, it has examples, pictures, and tutorials on how to use each of the toolboxes. The search feature is also quite useful, it searches through their pdf documents and through the user-posed questions, too. | ||

- | ---- | + | \\ |

- | + | ==== Matlab reproducibility at SEP ==== | |

- | ===== Matlab reproducibility at SEP ===== | + | |

In the SEP reproducibility denomination system, Matlab figures are considered //Conditionally Reproducible// because they require a proprietary software package ("matlab"). There are two degrees of reproducibility: | In the SEP reproducibility denomination system, Matlab figures are considered //Conditionally Reproducible// because they require a proprietary software package ("matlab"). There are two degrees of reproducibility: | ||

Line 63: | Line 60: | ||

* **SEP Report reproducibility requirements**. In order for a figure to be considered CR for the SEP report, it must be generated using two files, a ".ml" file and a ".m" one. Both have the same name as the figure being generated - if the final target is "figurename.ps", the files will be called "figurename.m" and "figurename.ml". "figurename.m" will produce a single figure, but will not write it to disc. The only thing that "figurename.ml" does is call the "figurename.m" script then print to disc the file in EPS format. It will have only two commands:"figurename;\\ print -depsc2 junk_ml.ps"Note that the output file must always be called junk_ml.ps. If you do things this way, you do not need to write any rule for the target "figurename" in the Makefile. It is only necessary to specify the figure on the RESULTSCR list in the makefile, and the makerules will take care of the rest.**Why is it done like that:** I know it looks cumbersome, but this is in the Object Oriented spirit: the actual writing of the figure to disk is separated from the process of creating it, so if one day we decide we need the matlab scripts to produce jpeg or tiff figures we only have to write a simple perl script which will change the ".ml" files. And having a single main script for each figure, with the same name as the figure helps others understand what's in there. The targets are always named junk_ml.ps in the makefile so that if you change the figurename, you do not have to edit matlab files as well.**Troubleshooting the Matlab makerules**: If the make rules "do not understand" that they are supposed to produce a matlab target without a rule, you can write a rule for a CR target in your makefile in the following way: "\\ ${RESDIR}/figurename.ps: $(MATLABDIR)/figurename.m \ \\ $(MATLABDIR)/figurename.ml \\ _TAB_here_@-cd $(MATLABDIR); matlab < figurename.ml\\ _TAB_here_mv $(MATLABDIR)/junk_ml.ps $@\\ _TAB_here_echo 'In order to produce this figure you need Matlab' > ${RESDIR}/figurename.warning " | * **SEP Report reproducibility requirements**. In order for a figure to be considered CR for the SEP report, it must be generated using two files, a ".ml" file and a ".m" one. Both have the same name as the figure being generated - if the final target is "figurename.ps", the files will be called "figurename.m" and "figurename.ml". "figurename.m" will produce a single figure, but will not write it to disc. The only thing that "figurename.ml" does is call the "figurename.m" script then print to disc the file in EPS format. It will have only two commands:"figurename;\\ print -depsc2 junk_ml.ps"Note that the output file must always be called junk_ml.ps. If you do things this way, you do not need to write any rule for the target "figurename" in the Makefile. It is only necessary to specify the figure on the RESULTSCR list in the makefile, and the makerules will take care of the rest.**Why is it done like that:** I know it looks cumbersome, but this is in the Object Oriented spirit: the actual writing of the figure to disk is separated from the process of creating it, so if one day we decide we need the matlab scripts to produce jpeg or tiff figures we only have to write a simple perl script which will change the ".ml" files. And having a single main script for each figure, with the same name as the figure helps others understand what's in there. The targets are always named junk_ml.ps in the makefile so that if you change the figurename, you do not have to edit matlab files as well.**Troubleshooting the Matlab makerules**: If the make rules "do not understand" that they are supposed to produce a matlab target without a rule, you can write a rule for a CR target in your makefile in the following way: "\\ ${RESDIR}/figurename.ps: $(MATLABDIR)/figurename.m \ \\ $(MATLABDIR)/figurename.ml \\ _TAB_here_@-cd $(MATLABDIR); matlab < figurename.ml\\ _TAB_here_mv $(MATLABDIR)/junk_ml.ps $@\\ _TAB_here_echo 'In order to produce this figure you need Matlab' > ${RESDIR}/figurename.warning " | ||

- | ---- | + | \\ |

- | + | ==== Accelerating Matlab's 3D graphics ==== | |

- | ===== Accelerating Matlab's 3D graphics ===== | + | |

**PROBLEM:**On the new Matlab 6.0, when running a command such as surf, that produced a 3D display, the thing would take a huge time to display, or would crash, and sometimes the following error would appear: | **PROBLEM:**On the new Matlab 6.0, when running a command such as surf, that produced a 3D display, the thing would take a huge time to display, or would crash, and sometimes the following error would appear: | ||

Line 73: | Line 69: | ||

**SOLUTION:** If before running your surf command you run: "set(gcf,'renderer','zbuffer')", the 3D image will display correctly and very fast, too. | **SOLUTION:** If before running your surf command you run: "set(gcf,'renderer','zbuffer')", the 3D image will display correctly and very fast, too. | ||

- | ---- | + | \\ |

==== Troubles to create tiff file from matlab to be included in Power Point ==== | ==== Troubles to create tiff file from matlab to be included in Power Point ==== | ||

Line 83: | Line 78: | ||

// set (gcf,'XDisplay','santorin.stanford.edu:0.0') // | // set (gcf,'XDisplay','santorin.stanford.edu:0.0') // | ||

- | ---- | ||

- | ===== How to correctly apply the graphics patches shown above ===== | + | \\ |

+ | ==== How to correctly apply the graphics patches shown above ==== | ||

- Open a //LOCAL MACHINE// window and type: xhost +ashland | - Open a //LOCAL MACHINE// window and type: xhost +ashland | ||

- Add the following code sequence just before the plot command that was giving you problems:"figure;\\ set(gcf,'renderer','zbuffer');\\ [s,w] = unix('echo $DISPLAY');\\ set(gcf,'XDisplay',w);"You should at least be able to //export// your figure as a "EPS file". There may still be problems with other file types. If your script/program contains variables called "s" or "w", change the respective variable names in the code sequence above. | - Add the following code sequence just before the plot command that was giving you problems:"figure;\\ set(gcf,'renderer','zbuffer');\\ [s,w] = unix('echo $DISPLAY');\\ set(gcf,'XDisplay',w);"You should at least be able to //export// your figure as a "EPS file". There may still be problems with other file types. If your script/program contains variables called "s" or "w", change the respective variable names in the code sequence above. | ||

- | ---- | ||

- | |||

- | ===== Dealing with Matlab's memory fragmentation problem ===== | ||

+ | \\ | ||

+ | ==== Dealing with Matlab's memory fragmentation problem ==== | ||

Recently, I gave Matlab a job that required it to go through roughly 400 iterations. The job involved adding some numbers into a big matrix, nothing complex. To my surprise, after 10 hours, it still had not finished running. | Recently, I gave Matlab a job that required it to go through roughly 400 iterations. The job involved adding some numbers into a big matrix, nothing complex. To my surprise, after 10 hours, it still had not finished running. | ||

I had matlab display a iteration counter. The speed of iteration slowed down fast after the first iterations, and I knew there were no convergence problems, so Matlab was sabotaging itself. I included the coomand "[[http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pack.shtml|pack]]" inside the loop, and the program executed in five minutes what previously had not been able to do in 10 hours! | I had matlab display a iteration counter. The speed of iteration slowed down fast after the first iterations, and I knew there were no convergence problems, so Matlab was sabotaging itself. I included the coomand "[[http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pack.shtml|pack]]" inside the loop, and the program executed in five minutes what previously had not been able to do in 10 hours! | ||

- | ---- | + | \\ |

- | + | ==== Exporting professional-quality figures ==== | |

- | ===== Exporting professional-quality figures ===== | + | |

//Matlab Digest// describes how to export figures for publications in a reproducible, automatized manner. Links to [[http://www.mathworks.com/company/digest/june00/export/|part 1]] and [[http://www.mathworks.com/company/digest/december00/export.shtml|part2]] of the article. The functions they provide ("exportfig", "previewfig", "applytofig", "restorefig") are now installed on koko too. The [[http://www.mathworks.com/support/tech-notes/1200/1206.shtml|Technical Support Guide to Printing]] is a good resource too. | //Matlab Digest// describes how to export figures for publications in a reproducible, automatized manner. Links to [[http://www.mathworks.com/company/digest/june00/export/|part 1]] and [[http://www.mathworks.com/company/digest/december00/export.shtml|part2]] of the article. The functions they provide ("exportfig", "previewfig", "applytofig", "restorefig") are now installed on koko too. The [[http://www.mathworks.com/support/tech-notes/1200/1206.shtml|Technical Support Guide to Printing]] is a good resource too. | ||

- | ---- | + | \\ |

- | + | ==== LaTeX in Matlab ==== | |

- | ===== LaTeX in Matlab ===== | + | |

Matlab already handles naturally simple LaTeX encodings that allow introducing Greek lettters or modifying the font size and appearance in plots. The function [[http://www.mathworks.com/matlabcentral/fileexchange/Files.jsp?type=category&id=11&fileId=1231|"teximage"]] (now installed on ashland too) converts //any// LaTeX string to images and displays them in Matlab figures. | Matlab already handles naturally simple LaTeX encodings that allow introducing Greek lettters or modifying the font size and appearance in plots. The function [[http://www.mathworks.com/matlabcentral/fileexchange/Files.jsp?type=category&id=11&fileId=1231|"teximage"]] (now installed on ashland too) converts //any// LaTeX string to images and displays them in Matlab figures. | ||

- | ---- | + | \\ |

- | + | ==== Adding noise to an image ==== | |

- | ===== Adding noise to an image ===== | + | |

The function "noise.m", now installed on ashland too, adds Gaussian, uniform, salt and pepper, additive or multiplicative noise to an image. | The function "noise.m", now installed on ashland too, adds Gaussian, uniform, salt and pepper, additive or multiplicative noise to an image. | ||

- | ---- | + | \\ |

- | + | ==== Running Matlab without graphics ==== | |

- | ===== Running Matlab without graphics ===== | + | |

Sometimes you may want to run scripts which contain plotting commands without displaying the plots and without going into the script to comment out the commands. An example: if you're working from home and it's too slow to run graphics over the network. You can play a simple UNIX trick: | Sometimes you may want to run scripts which contain plotting commands without displaying the plots and without going into the script to comment out the commands. An example: if you're working from home and it's too slow to run graphics over the network. You can play a simple UNIX trick: | ||

" % setenv DISPLAY /dev/null\\ % matlab "\\ | " % setenv DISPLAY /dev/null\\ % matlab "\\ | ||

+ | |||

+ | \\ \\ | ||

+ | {{page>share:footer&nofooter&noeditbtn}} | ||

+ |