Difference between revisions of "MATLAB"
(→colormap) |
|||
(4 intermediate revisions by one other user not shown) | |||
Line 2: | Line 2: | ||
matlab -nojvm | matlab -nojvm | ||
+ | |||
+ | While running matlab, one can still use the unix commands by adding "!" in the beginning. For example, to open a file using vim, type the following: | ||
+ | |||
+ | !vim file.txt | ||
+ | |||
This opens MATLAB without using the java interface (the virtual machine). | This opens MATLAB without using the java interface (the virtual machine). | ||
Line 14: | Line 19: | ||
set(gcf,'PaperPositionMode','auto'); | set(gcf,'PaperPositionMode','auto'); | ||
set(gca,'FontSize',12); | set(gca,'FontSize',12); | ||
+ | |||
+ | The parm 'PaperPositionMode' set as 'auto' will have matlab print the figure as it appers on screen. see following link. | ||
+ | |||
+ | [http://www.mathworks.com/help/techdoc/creating_plots/f3-124745.html http://www.mathworks.com/help/techdoc/creating_plots/f3-124745.html] | ||
Note that if you have a multi-paneled graph each panel have its own handle. | Note that if you have a multi-paneled graph each panel have its own handle. | ||
Line 31: | Line 40: | ||
[[Image:Matlab panel in panel.png]] | [[Image:Matlab panel in panel.png]] | ||
− | == colormap == | + | == Heatmap and colormap == |
Here are some possible color maps. | Here are some possible color maps. | ||
Line 58: | Line 67: | ||
% zero is in the center | % zero is in the center | ||
colormap(map) | colormap(map) | ||
+ | |||
+ | == Useful Matlab Functions written by Rizzo group == | ||
+ | |||
+ | [[fourier_fit]] | ||
+ | |||
+ | This Matlab function fits Fourier series to data, written by Trent E. Balius |
Latest revision as of 17:51, 14 January 2013
To access the lab version of MATLAB log on to ringo.ams.sunysb.edu and type the following:
matlab -nojvm
While running matlab, one can still use the unix commands by adding "!" in the beginning. For example, to open a file using vim, type the following:
!vim file.txt
This opens MATLAB without using the java interface (the virtual machine).
Contents
Making large plots
First create a new figure, maximize it. Add these commands after the plot() and before making labels and printing. This will create a 1000 x 1000 px plot
set(gcf,'Position',[1 1 1000 1000]); set(gcf,'PaperPositionMode','auto'); set(gca,'FontSize',12);
The parm 'PaperPositionMode' set as 'auto' will have matlab print the figure as it appers on screen. see following link.
http://www.mathworks.com/help/techdoc/creating_plots/f3-124745.html
Note that if you have a multi-paneled graph each panel have its own handle.
subpanel in a panel
figure(1) h = uipanel subplot(1,1,1,'Parent',h),plot([1:.1:10],sin([1:.1:10]/10*pi)) h2 = uipanel('Parent',h,'position',[0.4108 0.4096 0.2090 0.2157]) subplot(1,1,1,'Parent',h2),plot([1:.1:10],sin([1:.1:10]/10*pi))
make the background white.
set(h,'BackgroundColor',[1 1 1]) set(h,'ShadowColor',[1 1 1]) set(h2,'ShadowColor',[1 1 1]) set(h2,'BackgroundColor',[1 1 1])
Heatmap and colormap
Here are some possible color maps.
map =[1 0 0; %red 1 0.3 0.3; %light red 1 0.7 0.7; 1 1 1; %white 0.7 0.7 1; 0.3 0.3 1; %light blue 0 0 1]; %blue v1 = ones(1,101); x = [0:100]/100; map = [(1-x)' (1-x)' v1'; 0 0 0; 0 0 0; v1' x' x']; %white - blue - black - red - white map = [ v1' x' x'; 1 1 1; 1 1 1;(1-x)' (1-x)' v1']; %red - white - blue
Make a heatmap using the one of the color maps above.
H1 is a NXM matrixs
val1 = max(max(abs(H1))); val2 = max(max(abs(std1))); figure(num), imagesc(H1), % makes heatmap colorbar, caxis([-val1,val1]) % this specifics the range of the color axis % zero is in the center colormap(map)
Useful Matlab Functions written by Rizzo group
This Matlab function fits Fourier series to data, written by Trent E. Balius