diff options
-rw-r--r-- | matlab_usage_source/index.t2t | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/matlab_usage_source/index.t2t b/matlab_usage_source/index.t2t index 7ec51aa..6da711e 100644 --- a/matlab_usage_source/index.t2t +++ b/matlab_usage_source/index.t2t @@ -4,14 +4,38 @@ Matlab usage - short (may be too short) introduction %!style(html): ../evmik.css += Why Matlab = + +At the very least, it is a great replacement of a hand held calculator. Once +you need to process multiple data point it became tedious with a simple +calculator. Once you master Matlab it will not matter if it is one data +point or millions of them. It can do complex math, plotting, fitting, etc. +It is also the complete programming language which can stand by itself. +Also, Matlab has excellent help documentation and a lot of tutorials at the web. + +There are free alternatives. [Octave http://www.gnu.org/software/octave/] +is one example. This what I personally use +instead of Matlab all the time. But it is a bit difficult with installation +and it might be scary to see no GUI and only a command prompt for a +beginner. + += Getting Matlab = + +Please visit W&M IT [software support page http://www.wm.edu/offices/it/a-z/software/] +and download Matlab from appropriate "Licensed Software >> Math & Statistics +Software" section. They have several available versions. Either one is fine. +Since we are learning Matlab, we will not have time to go to fancy toolboxes +which Matlab provides/removes with new releases. + = How to make a simple plot = Suppose during the measurements we obtain the following data -fir each parameter 'I' we measured 'V' with a particular uncertainty dV. -Our data is represented in the following table. +for each current value 'I' we measured voltage 'V' +with some uncertainty in voltage measurement dV. +Our experimental data is represented in the following table. || I | V | dV | -| .1 | 1.0 | 0.2 | +| 0.1 | 1.0 | 0.2 | | 1.0 | 2.2 | 0.1 | | 1.8 | 3.2 | 0.2 | | 3.3 | 3.8 | 0.2 | @@ -27,7 +51,7 @@ dV = [ 0.2; 0.1; 0.2; 0.2; 0.3 ] ``` Now we make a simple plot without error bars to get the basic, text after -**%** is considered as a comment and matlab will disregard it. +**%** is considered as a comment and Matlab will disregard it. ``` figure(1) % all plotting output will go to the particular window @@ -85,7 +109,11 @@ ylabel('Current (A)') = Fixing plots font size = -Honestly Matlab is not the best tool to do presentation quality plots, it requires a quite a bit of messing with their GUI. But at least for quick font size fix do the following. This looks a bit like magic spell. +Honestly Matlab is not the best tool to do presentation quality plots, it +requires a quite a bit of messing with their GUI. But at least for a quick font +size fix do the following. This might look like a magic spell so do read documentation +on **``set``** command. + ``` fontSize=24; set(gca,'FontSize',fontSize ); @@ -99,19 +127,28 @@ ylabel('Current (A)') [errorbar_with_large_font_plot.png] -= Saving you matlab plots = += Saving you Matlab plots = -Well it nice to have matlab plots. But as soon as you close matlab they will go away. -How to save them for a future use? Actually, quite easy. -For png output do +Well it nice to have Matlab plots. But as soon as you close Matlab they will go away. +How to save them for a future use? Actually, quite easy with **``print``** command. Unlike the name suggest it does not make a carbon copy but actually an electronic one. + +For figure saved in png format do ``` print('V_vs_I.png') -or if you need a pdf (matlab usually make very bad pdfs) +or if you need a pdf (Matlab usually make very bad pdfs without a lot of tweaking) ``` print('V_vs_I.pdf') -Make sure that you read documentation for **``print``** command there are some useful parameters. +Make sure that you read documentation for **``print``** command there are some +useful parameters. + += Where to learn more = +At W&M Physics 256 class teaches how scientists use computers. Matlab was a language of +choice for this class. Feel free to read and use +[my Physics 256 materials http://physics.wm.edu/~evmik/classes/2012_fall_practical_computing_for_scientists/] +make sure that you read at least Lecture 02 slides. Also lecture 15 slides discuss +data reduction and fitting. |