User Tools

Site Tools


matlab

Matlab

These lines of code help make a better looking plot that can be exported for a notebook or a publication.

x=[400:1:450];
y=2*sin(x/5);
figure('units','centimeters','Position', [10 10 8.5 8.5])
p=plot(x,y,'LineWidth',1.1); %make curve slightly thicker than default
set(gca,'linewidth',1.1)  %make axis slightly lines thicker than default
axis([400 450 0 3])
xlabel('wavelength, \lambda (nm)') %LaTeX notation for math symbols
ylabel('intensity (W/cm^2)') %LaTeX notation for superscript
set(gca,'FontSize',10) %10 point font when used as 8.5 cm figure.

Additional pointers about graphs on Matlab.

  • If your data is very big or very small, multiply the data by a scaling factor and note this scaling factor in the units. For example, rather than plot 1e-8 amperes, multiply by 1 billion and plot as 10 nA.
  • From the menus associated with the figure, go to “file > export setup > rendering”, and set the resolution to 300 dpi or 600 dpi (“apply to figure”).
  • From the menus associated with the figure, go to “file > save as”, and save as a png file. Choose png because it is much better than jpg for line graphics.
matlab.txt · Last modified: 2024/05/23 15:58 by ethanminot