Software Type | MS Windows | Linux | |
---|---|---|---|
Internet-browsing and File-management | IExplorer, FireFox | <=> |
FireFox (except IE-specific services like Outlook Web Mail) |
MS Outlook, The Bat!, Thunderbird | <=> |
Thunderbird | |
Far Manager | <~> |
Midnight Commander | |
Explorer | <=> |
Nautilus, Konqueror | |
PuTTY + RealVNC/TightVNC; WinSCP, Far+NetBox | <=> |
x11vnc + RealVNC (remote control); mc (file transfer) | |
Bibliography and Writing | Adobe Reader | <~> |
Evince, Okular, KPDF |
Adobe Acrobat Pro | <~> |
PdfEdit + pdftk | |
MiKTeX | <=> |
teTeX, TeX-Live | |
TeXnicCenter, WinEdt | <~> |
Kile, Emacs | |
JabRef, Zotero, Endnote | <=> |
JabRef (LaTeX oriented BibTeX database), Zotero | |
MS Word + MathType | <~> |
LibreOffice.Writer + TexMaths | |
Graphics, Plotting and Presentations | Adobe Photoshop | <~> |
Gimp |
CorelDraw, Adobe Illustrator, WinFig | <~> |
Xfig, Inkscape, PSTricks | |
ACDSee | <~> |
ImageMagic (convert), ps2pdf, xv | |
ImageJ | <=> |
ImageJ (morphology analysis and image processing) | |
Origin, IGOR Pro, GNUPlot | <=> |
GNUPlot, matplotlib, Grace | |
PowerPoint + TeXPoint, LaTeX + Beamer | <~> |
LaTeX + Beamer, OOffice.Impress | |
Computations | MATLAB | <=> |
MATLAB, Octave, SciPython, SciLab |
Maple, Mathematica | <=> |
Maple, Maxima, Mathematica | |
R, SPSS, Stata | <=> |
R, SPSS, Stata | |
Visual Studio, Borland C++ Builder, Intel C, QT, Java | <~> |
vi/Emacs/Kedit + gcc, Java, Intel C, QT, ... | |
ANSYS (CFX, ...), ABAQUS, COMSOL, STAR-CD | <=> |
ANSYS (CFX, ...), ABAQUS, COMSOL, STAR-CD | |
about:config
in the address field and set
browser.preferences.inContent = false
browser.preferences.instantApply = false
about:config -> New -> String -> plugin.disable_full_page_plugin_for_types = application/pdf
about:config -> browser.urlbar.matchOnlyTyped = False
about:config -> New -> Boolean -> extensions.checkCompatibility.3.6 = False
3.6
is the first two numbers of Firefox's version).
about:config -> xpinstall.signatures.required = False
firefox -ProfileManager
(or firefox -P
) and then hitting the [Create Profile...]
button
firefox -no-remote
to run a new firefox instance rather than opening another window to existing process.Edit -> Preferences -> General -> Config Editor
and change the following property
mail.tabs.autoHide = true
.emailStar {display: none}
/chrome/userChrome.rss
which has to be put in the user profile (e.g. ~/.thunderbird/***.default/
in Linux).
File -> Inspect Chrome Document -> 'Inbox... Thunderbird'
#document/window/menuPopUp(mailContext)
to configure right-click menu)hidden="true"
to the right-hand-side 'Attributes' panelextensions.alwaysUnpack
to true
in the Settings->Advanced->Config Editor)
panacea.dat
from the main Thunderbird profile directory (source).
iconv -f cp1251 -t utf-8 input.txt -o output.txt
find . -name '*' | while read i; do iconv -f WINDOWS-1251 -t UTF-8 "$i" >tmp; mv tmp "$i"; done
convmv -r -f WINDOWS-1251 -t UTF-8 ./*
find . | perl -ane '{ if(m/[[:^ascii:]]/) { print } }' > Non-ASCII-filenames.txt
$HOME/.i18n
and put the following line in it:
LC_COLLATE=C
$HOME/.profile
file:
export LC_COLLATE=C
wine
virtual machine
LC_CTYPE=ru_RU.utf8 wine application.exe
(see more hints).
cal -m 2010
<Shift>
cat /proc/cpuinfo
or dmesg | grep CPU
cat /proc/cpuinfo | grep processor
tells the number of processors/cores);
cat /proc/meminfo
(in kB) or free -m
(in MB);
cat /etc/sysconfig/hwconf
;
df -h
(add -T
for fs type);
finger
;
uptime
or top
ifconfig
.
sudo lshw -class network
nmcli connection show
iwconfig wl...
smartctl -a /dev/hda
df -h
),
YYYYMMDDhhmm
touch -m -t 201003020000 FILENAME
*.csv
files in one, use
cat *.csv > merged.csv
rename 'old_prefix-' 'new_prefix-' ./*
./rename.pl 's/([0-9]+)/sprintf("%03d",$1)/e;' ./*
./rename.pl 's/\s/-/g' ./*
-n
option after a test run)
find . -name '*:*' -exec rename 's/:/-/g' {} -v -n \;
$HOME
directory, use
cd ~
find -regex './\..*' | tar cvfz ./dot_files.tar.gz -T -
find -regex './\..*' -exec tar zvfc dot_files.tar.gz {} +
more info.
$HOME/BIB_BACKUP/
and
mkdir $HOME/BIB_BACKUP
find $HOME \( ! -regex '.*/.*reserv.*' \) -iname "*.bib" -exec cp -au {} $HOME/BACKUP \;
find ./ \( ! -regex '.*/.*reserv.*' \) -iname "*.bib" -type f \
-exec grep -q OLDSTRING {} \; \
-exec perl -i.bak -pe "s/OLDSTRING/NEWSTRING/g" {} \; \
-printf "Processed file: %p\n"
-exec sed -ic "s/oldstring/newstring/g" {} \;
as the last operation.
{}
in the -exec
portion is substituted with the found filenames; '\' allows multiline commands,
-exec
statement. Also note that '{' has to be escaped like '\{' in Perl's 'oldstring'.
find ROOT_DIR -iname "FILETYPE" -exec cp {} TARGET_DIR \;
,
find ./ -iname "*.mp3" -exec mv {} ./global_storage/ \;
find $HOME \( ! -regex '.*/\..*' \) -type f -mtime 0
-mtime -n
means during the last n days
find . -xtype l
zip -rTog filename.zip /PATH/*
-m
to delete these files after archivation.
tar -cvf - DIR | 7z a -si -p DIR.tar.7z
tar -cavf DIR.tar.xz DIR/ #create .xz (use .gz for gzip)
tar -xvf DIR.tar.xz #extract .xz
7z a -mhe=on -p DIR.7z DIR
zip
-file, using
7z a -p DIR.zip DIR
7z x FILE
").
wget http://www.midnight-commander.org/downloads/mc-4.6.1.tar.gz
tar -xzvf mc-4.6.1.tar.gz
cd mc-4.6.1
./configure --silent --prefix=$HOME/.mc
--prefix
says where to install, subject to your rights to do so,
--silent
suppresses the auxiliary output)make
make install
bin/
directory (in this case you can
$HOME/.mc/bin/mc
). However obvious it may sound, it is better to have
./synch_dir PATH_TO_DIR
, where
PATH_TO_DIR
is the root path to the directory tree to be synchronised
#!/bin/sh
# run for every child directory of $1
find $1 -type d | while read path; do
# get the latest modified file in the tree $path
fname=$(find "$path" -type f -printf "%T+\t%p\n" | sort -n | tail -1 | cut -f2);
# set the modif. date of $path to match the attribute of $fname
touch -m -c -r "$fname" "$path";
done
chmod -R u=rwX,g=rX,o=rX ./*
chmod +t ./SHARED
sudo ./photorec_static
sudo ./testdisk_static
PhotoRec
seems more straightforward and reliable on FAT32 USB stick-like media.
diff --side-by-side File1 File2
Eclipse
).
settings -> edit profile -> appearance -> black on white
). Alternatively, use
edit -> profile preferences -> colours -> pallete -> Linux console
.
sudo apt-get update
sudo apt-get install PACKAGE_NAME # for installing from a repository
sudo dpkg -i PACKAGE_FILE.deb # for a downloaded file
sudo apt-get install -f
apt-cache search PACKAGE_NAME
apt-file search .so-FILE_NAME
sudo apt-get remove --purge PACKAGE_NAME
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
# test
symlinks -rst ~/disk/*
# run
symlinks -rsc ~/disk/*
gnome-session-properties
(e.g. with Alt + F2
) and select
Options --> Automatically remember running applications...
~/.local/share/applications/mimeapps.list
.
MyApp.desktop
in ~/.local/share/applications/
with the following content:
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/PATH_TO_APP/MyApp.sh %f
Name=MyApp
Icon=/PATH_TO_APP/MyApp-icon.png
properties -> open with -> set as default
. (see also .desktop format specification)
gconf-editor
, then go to
apps -> metacity -> global_keybindings
and afterwards to keybinding_commands
.
dconf-editor
and find
org -> mate -> marco -> global_keybindings
respectively.
dconf dump / | grep keyword :: search dconf for an entry
dconf reset -f /org/matel/panel/objects/object-n/ :: delete phantom object n
gsettings set org.gnome.nautilus.preferences sort-directories-first true
gsettings set org.gtk.Settings.FileChooser sort-directories-first true
dconf
editor; source).
Shell link
,
ssh -X
):
PuTTy -> Connection -> SSH -> X11-> Enable
$ xfe
as simple GUI, or $ mc
as text-style, file-manager (install sudo apt install xfe
on the target Linux server, if necessary)
nohup
:
$ ssh username@remote-server
$ nohup my_command > my_command.log 2>&1 &
$ exit
disown
:
$ my_command > my_command.log 2>&1 & # script or GUI
$ disown -a && exit
screen
:
screen
to detach/re-attach a remotely running Malab script.
screen
: quickref.me/screen.
Format --> Paragraph --> Text flow
Breaks
area, enable Insert
. Enable With Page Style
just to be able to set the new Page number
. Click OK.
Insert --> Fields --> Page Number
Edit --> Search & Replace
[x] Entire cells
0
to the first row of the empty column
Edit --> Fill --> Below
.
Save as -> Text CSV
and then tick
[x] Edit filter settings
at the bottom-left corner before clicking on Save
.
.*[ab]_.*
, and tick "Regular expression" in Options.
AVERAGEIF(B1:B10,">10", A1:A2)
[Preamble]
;.odt
format to ensure
that all formulas are not disturbed when you open the file again.pdftk
command-line backend:
sudo apt-get install pdfchain
pdftk file1.pdf file2.pdf cat output final.pdf
pdftk *.pdf cat output final.pdf
pdftk file.pdf cat 1east 2-end output fileRotated.pdf
./pdfrotate odd 180 input.pdf output.pdf
pdftk A=input.pdf shuffle A1-endoddsouth A1-endeven output final.pdf
pdftk A=odd_pages.pdf B=even_pages.pdf shuffle A1-end Bend-1 output final.pdf
pdftk file.pdf output fileFixed.pdf
smpdf
is availabe from the CPDF toolkit:
smpdf input.pdf -o output.pdf
cpdf
, use the following syntax instead:
cpdf -squeeze input.pdf -o output.pdf
shrinkpdf
:
./shrinkpdf input.pdf output-small.pdf
#(use 150 dpi instead of default 72)
./shrinkpdf input.pdf output-small.pdf 150
pdftk in.pdf cat output protected.pdf owner_pw MasterPass user_pw OpenPass
cpdf
(see more CPDF examples):
cpdf -encrypt 128bit MasterPass OpenPass in.pdf -o protected.pdf
pdftk protected.pdf input_pw MasterPass cat 1 3-end output decrypted.pdf
pdftk protected.pdf cat 1 3-end output decrypted.pdf do_ask
cpdf
command is
cpdf -merge protected.pdf owner=MasterPass 1,3-end -o decrypted.pdf
pdftk
by default revokes all permissions (including printing), while
cpdf
allows printing, copying, etc. unless told otherwise. Also, cpdf
preserves original 'creator'
pdftk
overwrites the metadata with its own.
for f in *.pdf; do pdftk $f cat output ${f%.*}-e.pdf owner_pw MasterPass user_pw OpenPass; done
pdftk protected.pdf cat 1 output first_page.pdf do_ask
qpdf --decrypt protected.pdf --password="" out.pdf
tiffcp *.tiff OUTPUT.tiff
jpeg
compression)
tiff2pdf -j -o OUTPUT.pdf INPUT.tiff
for f in *.tiff; do convert -compress jpeg -quality 75 $f ${f%.*}.pdf; done
pdftk *.pdf cat output final.pdf
pdftotext
and works only with text-based or OCR PDFs (not image-only scans).
find . -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "SEARCH STRING"' \;
okular
or evince
), use
Master PDF Editor
(free for non-commercial use).
\usepackage{sagetex}
...
\sageplot[angle=30, width=5cm]{plot(sin(x), 0, pi), axes=False}
latexdiff old.tex new.tex > diff.tex
latexdiff
doing this is available at CTAN
latexdiff-so
instead).
ps2ascii
ps2ascii file.pdf | wc
hyperref
package warning: Token not allowed in a PDFDocEncoded string...,
\texorpdfstring{$Your Formula$}{Equivalent Text}
\section{}
, \subsection{}
, etc. (see also other hyperref problems).
-Ppdf
to dvips
command line (e.g. in Kile/WinEdt settings).
\usepackage[T1]{fontenc}
but use {\fontencoding{T1}...}
locally instead.
\usepackage[...]{hyperref}
, NOT in the \hypersetup{...}
:
\usepackage[plainpages=false,pdfpagelabels]{hyperref}
minipage
environment with plain-TeX \vss
to make LaTeX ignorant of extra height:
\begin{figure}[p]
\begin{minipage}[t][\textheight]{\textwidth}
\centering \vspace{-1em} % some tweaking
\includegraphics{...}
\vspace{-0.5em} \caption{...} \label{fig:...}
\vss % hides extra height
\end{minipage}
\end{figure}
\label
always go inside or straight after the \caption
.
\usepackage{afterpage}
package, providing a
\afterpage{ \do_something_after_this_page_ends }
. For example,
\afterpage{\clearpage}
\begin{figure}
...
\caption{Blah-blah-blah \protect\footnotemark .}
\end{figure}
\afterpage{ \footnotetext{Some clarification.} }
... e.g.\ we can avoid here an extra space.
\textstyle
command in the display mode switches fonts and spacing
\textsyle\sum e^{\textstyle a/b}
\displaystyle
, \scriptstyle
and \scriptscriptstyle
.
JabRef
:
#!/bin/sh
java -jar /PATH_TO_JabRef/JabRef-2.6.jar --import $(readlink -f $1)
JabRef.exe
itself in MS Windows)
Open with...
in Firefox each time when you encounter a .ris-file or the like.
Preferences --> Advanced --> Remote Operation
in JabRef.
Scholar Preferences --> Show links to import citations into BibTeX
)Cite/Export --> Export a Citation
)right-click
in the entry editor
Change case
.
[LyX/Kile]
button in JabRef:
.lyx
in your home folder;Preferences -> External Programmes
, click on the [LyX]
button,
/FULL_PATH_TO_HOME/.lyx/lyxpipe.in
and save.[LyX/Kile]
button and enjoy imported BibTeX keys.
{ }
Options -> Preferences ->
General -> File -> "Store the following fields with braces around capital letters"
title;journal;author
.
\begin{author}\format[Authors(LastFirst,NoPunc,InitialsNoSpace),HTMLChars,Replace(A Name,<strong>A Name</strong>)]{\author}\end{author}
sudo apt-get install libreoffice-java-common
Tools --> OpenOffice/LibreOffice Connection
, click on [Manual Connect]
, and set 'path to executable' to
/usr/lib/libreoffice/program/soffice.bin
and 'path to library dir' to /usr/lib/libreoffice
.
See installation instructions if you wish to try.
Some tips:full-display
mode when you edit formula, as it gives you full control
\documentclass[a4paper,12pt]{article}
\usepackage{amssymb,amsmath,latexsym}
\usepackage[usenames]{color}
\pagestyle{empty}
\begin{document}
\begin{equation*}
\begin{gathered}
\color[rgb]{0,0,0}
...
a^2 + b^2 = c^2
...
\end{gathered}
\end{equation*}
\end{document}
Format -> 256 colors PNG
..eps
, .jpeg
, etc. figures. It is usually included in most Linux distributives (if not, you can download it for free). A Windows version is available as shareware WinFIG.
sudo apt-get install xfig gsfonts-x11
.png
or other bitmap image, do not forget to
'some smoothing'
or 'more smoothing'
option, otherwise you may
Position
property (bottom toolbar) to "any"
Edit
tool to tweak its coordinates arbitrary.
.eps
file is to use the fig2eps utility by Marc de Courville and others
$ $
,
diagram.fig
, and run from the console:
fig2eps diagram.fig
diagram.eps
, ready to be
-times
fig2eps -h
for more details).
-------------To crop an imported image
InkScape Tips
-------------
Object -> clip -> set
File -> Document Properties -> Background colour
and set Alpha
(opacity) to 255.See a good comparative
Overview of Graphical tools, and a wiki-introduction.
TeXnical Manulas: PsTricks,
ps-plot.
\usepackage{pst-math,pst-plot,pstricks}
...
\begin{figure}[tp]
\centering
\psset{unit=1.2cm} % use this to scale the picture
\psset{plotpoints=500} % plotting quality (def=50)
\begin{pspicture*}(-0.5,-0.5)(5,3)
% set up axis: (centrx,centry)(minx,miny)(maxx,maxy)
\psaxes[labels=none,ticks=none]{->}(0,0)(0,0)(4.5,2.5)
\rput(4.5,-0.25){ $t$} % label axes
\rput[t](-0.35,2.5){$f(t)$}
% plot f(t) = 2*exp(-5*(t-1)), using Reverse Polish Notation
\psplot[linecolor=blue,linewidth=1.25pt]{1}{3}%
{ 1 neg x add 5 mul neg EXP 2 mul } % x is the argument
% plot a horizontal line and a label
\psline[linecolor=red,linestyle=dashed,linewidth=0.75pt]%
(0,1.5)(4,1.5) \rput(-0.25,1.4){\small$\frac{a}{b}$}
% plot a vertical line
\psset{linecolor=blue,linewidth=1pt,linestyle=dotted}
\psline(2,0)(2,2) \rput(2,-0.25){\scriptsize$\tau$}
\end{pspicture*}
\caption{PSTricks-graph}\label{fig:pstricks-graph}
\end{figure}
c/d + b*exp(-a*x) = x a neg mul EXP b mul c d div add
EXP
, from the package pst-math.
\psset{algebraic=true}
\string~
' tip to handle tildes in the url correctly).
See a brief overview or comprehensive online ImageMagick documentation if you have plenty of spare time...
.eps
to .png
use
convert -density DPI -resize WIDTH_PIXELSxHEIGHT_PIXELS -rotate ANGLE file_name.eps file_name.png
convert -density 150 -resize 1024 file_name.eps file_name.png
-sharpen 0xsigma
or -unsharp 0xsigma+amount+threshold
-sharpen 0x1
) can be used to reduce a blur, where \sigma is a parameter
convert file.jpg file.eps
), either specify format explicitly
convert file.jpg file.eps2
) or force the output format:
convert -density 150 file.jpg eps2:file.eps
.png
to .eps
, use the following (in Linux command-line):
for f in *.png; do convert -density 300 $f eps2:${f%.*}.eps; done
FOR %f IN (*.png) DO convert -density 300 %f eps2:%~nf.eps
img2pdf --output merged.pdf *.png
imagemagick
pipeline:
convert *.png merged.pdf
convert FILENAME -verbose info:-
identify -verbose FILENAME
.eps
figure produced by MATLAB, use
convert figure.eps temp.eps
convert -trim +repage -density 150 temp.eps figure_final.eps
convert -crop +0+50 +repage figure.png figure_cropped.png
ps2pdf -dEPSCrop input.eps output.pdf
-dPDFSETTINGS=/prepress
(or =/print
)
epstopdf input.eps
pdf2ps -sDEVICE=epswrite input.pdf output.eps
pdftops -eps input.pdf output.eps
-dUseCIEColor
is an extra option that makes device-independent colours for printing):
# create a .pdf from .eps
ps2pdf -dEPSCrop -dPDFSETTINGS=/printer -dUseCIEColor \
-dCompatibilityLevel=1.3 -dMaxSubsetPct=100 -dSubsetFonts=true \
-dEmbedAllFonts=true figure.eps figure.pdf
# check the fonts
pdffonts figure.pdf
# convert back to .eps
pdftops -eps figure.pdf figure-emb.eps
for f in *.eps; do convert -density 400 -depth 8 -alpha off -compress LZW $f ${f%.*}.tiff; done.
mogrify -mattecolor white -frame 2x2 *.tiff
sudo add-apt-repository ppa:strukturag/libheif
sudo apt install libheif-examples
heif-convert input.HEIC output.jpg
tifig -v -p --width 800 input.HEIC output.jpg
convert -delay 120 -loop 0 *.jpg animated.gif
ImageMagick
and ffmpeg
:
convert input.gif temp%05d.png
ffmpeg -i temp%05d.png -r 10 -qscale 0 output.avi
rm temp*.png
-r
defines the frame rate in Hz, and -qscale
preserves the quality).
convert input.gif -scale 50% -fuzz 2% +dither -layers Optimize output.gif
ffmpeg
, simply change the extention, e.g. to output.mov
.
ffmpeg -i video.mp4 -vf "crop=720:520:120:0" -f gif video.gif
-vf
option above that crops the original video before converting.
ffmpeg
installed, you could do it on Ubuntu with
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg
1e15 * sum([-10, 1e-15, 10])
?
1e15 * sum([-10, 10, 1e-15])
gives you unity as expected.
if ( 12345678901234567^3 + 2^3 == 12345678901234568^3 )
disp('be careful with floating-point arithmetic')
end
Configure Window Behaviour...
.
Window-Specific Settings -> [New...] -> [Detect]
. Click on any MATLAB window,
"Whole window class"
. Finally [Geometry] -> Desktop -> Force -> Desktop 5
.
(Default) Disable focus stealing prevention for MATLAB Windows class;
sun-awt-x11-xframepeer com-mathworks-util-postvminit [exact match]
[Geometry] -> Desktop -> Force , 5
[Workarounds] -> Allows focus stealing prevention
--------------------------------For MATLAB newer than 7.8.* (2009), the multithreading (using more than one
DISTRIBUTED MULTI-CORE COMPUTING
--------------------------------
feature('NumCores')
memory
parfor
from the Parallel Computing Toolbox to split the for
-cycle between
matlabpool open local 2
...
parfor i = (1 : N)
B(i) = function(A(i))
end
...
matlabpool close
NumWorkers
property.
NUM_CORES = 4;
myCluster = parcluster('local');
myCluster.NumWorkers = 12; saveProfile(myCluster);
matlabpool('open', 'local', NUM_CORES);
----------------------Note that the scaling of an
GRAPHICS AND EXPORTING
----------------------
.eps
-figure depends on the screen resolution you set
I = getframe(gcf);
imwrite(I.cdata, 'FileName.png');
hh = get(gca, 'Children');
XX = get(hh,'XData'); % or get(hh(1),'XData') if more
YY = get(hh,'YData'); % than one line was plotted
hh
.
'Newton''s law'
line('XData',x, 'YData',y, 'LineStyle','none', ...
'Marker','o', 'MarkerSize',7, 'MarkerFaceColor',[0,0,0]);
x,y
can be vectors to draw a set of points.
hFig = figure('Name','MyFigure');
...
set(0, 'CurrentFigure',hFig); hold on;
figure('Name','Double-Axes Example'); hold on; box on;
XX = 1:0.1:10; YY1=sin(XX); YY2=exp(XX);
plot(XX, YY1, '-k', 'LineWidth',2);
hAx1 = gca;
hAx2 = axes('Position',get(hAx1,'Position'),...
'XAxisLocation','top', 'XTick',[],...
'YAxisLocation','right',...
'Color','none','XColor','k','YColor','k',...
'YScale','log'); hold on;
semilogy(XX, YY2,'--k', 'LineWidth',2, 'Parent',hAx2);
xlabel(hAx1, 'X', 'FontSize',16);
ylabel(hAx1, 'Y1', 'FontSize',16);
ylabel(hAx2, 'Y2', 'FontSize',16);
legend(hAx1, {'a'}, 'FontSize',12, 'Location','NorthWest');
legend(hAx2, {'b'}, 'FontSize',12, 'Color','w');
'HitTest','off'
when creating hAx2.
legend()
use {...}
for captions,
legend({'caption1','caption2'}, 'FontSize',12);
legend({'line^{index}_1', 'line_2'})
,
[hL,hLL,auxL,auxT] = legend( ... );
hText = findobj(hLL, 'type','text');
set(hText(end), 'VerticalAlignment','Cap');
'Cap'
aligns with the Capital letter (try also 'Top'
).
.eps
figure with a transparent background, use
set(gca, 'Color','none');
set(gcf, 'Color','none');
set(gcf,'InvertHardCopy','off');
print -depsc2 Transparent.eps;
chart('arial'); % prints out character table
pm_char = char(hex2dec('B1')); % \pm char based on its ascii value
mu_char = char(hex2dec('B5')); % \mu char
uicontrol('Style','text', 'String',[pm_char, ' 10 ', mu_char,'m']);
figure;
hax1 = subplot(2,1, 1);
colormap(hax1, 'jet');
surf(peaks(30)); hc=colorbar;
cbfreeze(hc); % freeze colorbar
freezeColors; % freeze colormap
hax2 = subplot(2,1, 2);
colormap(hax2, 'gray');
surf(10*peaks(100)); colorbar;
cbfreeze
and freezeColors
are unnecessary for MATLAB 8.4 (2014b) or newer,
colormap(h,...)
.
exponent = -2;
set(gca, 'YTickLabel', strtrim(cellstr(num2str(get(gca,'YTick')'/10^exponent))') );
fs = get(gca,'fontsize'); xl = xlim; yl = ylim; set(gca,'units','normalized');
text(xl(1),yl(2), sprintf('\\times10^{%d}',exponent), 'fontsize',0.9*fs, ...
'VerticalAlignment','bottom');
-----------Starting from MATLAB 2010a, a new option
MISCELLANEA
-----------
'index0'
will be available for most
zeros(), ones(), diag(), sum()
, etc.)
'Callback'
-option/value pair is either 'any Matlab code'
or
@mySubFunction_Callback
, the latter WITHOUT quotes (' '). The respective
@mySubFunction_Callback(hObj, event, eventdata)
.
clear Variable;
inside the script if the variable under question is global.
clear Variable; global Variable;
(LIST_OF_VARIABLES = {'AnArray', 'ACellArray', 'AScalar'};
for i = [1 : length(LIST_OF_VARIABLES)]
Info = whos(LIST_OF_VARIABLES{i});
if strcmp(Info.class, 'cell')
evalc([LIST_OF_VARIABLES{i}, ' = {}']);
else
evalc([LIST_OF_VARIABLES{i}, ' = []']);
end
end
Numbers = []; new_number=42;
Strings = {}; new_string='abc';
Numbers = [Numbers, new_number];
Strings = {Strings{:}, new_string};
% or even better
Strings = [Strings; {new_string}];
A( find(A == 3, 1,'last') );
% returns 'ans = 3'
% for A = [1, 2, 3, 3, 3];
3
, use
digits(3); A_sym = sym(A, 'd');
latex(A_sym);
screen
to emulate a terminal session and
matlab -nodisplay
to suppress the graphical support by using the
$ ssh username@chiron
$ screen
$ nice matlab -nodisplay -logfile ~/matlablog.txt -r myscript.m
...
press <Ctrl>+a, followed by d
$ logout chiron
$ ssh username@chiron
$ screen -r
exit
to close the session.
$ matlab -nojvm -nodisplay < my_script.m
$ matlab -nojvm -nodisplay -r my_script,quit
spy % plots a ... sparse matrix
why(0) % answers any question
sum * % gives the Answer to the Ultimate Question of Life
COMSOL Multiphysics (formerly known as FEMLAB) is an extensive Finite Elements Method-based solver for PDEs with graphical interface and excellent collaboration capabilities with MATLAB (which is not surprising as COMSOL was originally developed as a PDE Toolbox for MATLAB). There is a good and short introduction to this software package by Prof. Michael Hanke, highlighting one of its principles: the maximal flexibility, allowing a user to see and control actual PDEs and boundary conditions used by the solver. Some potential shortcomings of the COMSOL are a limited set of design and mesh generation tools and a restricted access to the solver data in MATLAB.
.mph
or .fl
binary formats;
.m
-file.
$ comsol mphserver matlab &
$ comsol &
$ comsol &
-mlroot /usr/local/matlab...
or
MLROOT=${MLROOT:=/usr/local/matlab...}
).
All Programs -> COMSOL Multiphysics -> License Tools -> LMTOOLS -> Browse ->
C:\Program Files\COMSOL\COMSOL61\Multiphysics\license\license.dat
,
$ cd /usr/local/comsol61/multiphysics/license/glnxa64
$ ./lmstat -a -c ../license.dat
[in Linux]: $ cd .../comsol61/multiphysics/license/glnxa64/
[in MacOS]: $ cd .../comsol61/multiphysics/license/mac...64/
$ ./lmborrow -status
[in Windows]: > lmutil lmborrow -status
-mesa
to the start-up script (see also
comsol35a -mesa &
q0 * u_test
,
g = q0
.
Point Settings
of a Point
Draw -> Geometric Properties
to make sure all points and lines are precisely at
1e-4
is easily introduced when
line1 = solid1([0,1]);
pt1 = point1(0.25); pt2 = point1(0.5);
p.objs = {pt1, pt2}; s.objs = {line1};
fem.draw = struct('p',p,'s',s);
fem.geom = geomcsg(fem);
Draw -> Specify Objects
.
Physics -> Periodic boundaries...
ellip2()
) and the one with only internal polygons (line2()
) has different indexing
'g_rect2 - g_line2 - g_ellip2'
) and apply type 1 b.c.
(1,1,1, 2,2,...,2, 1, 3,3,3,3)
.
comsol server matlab -compat -c35aroot /usr/local32/comsol35a -mlroot /usr/local/matlab7.10
Study Reference
: just add the component to Study 2 (transport sweep) and make it
Matlab LiveLink
scripting is also capable of this or more sophisticated automation.
Model Methods
from the Application Builder
R Project is an open-source powerful tool for statistical
manipulations (stemmed as a free alternative to S-PLUS). Its myriad of packages, like Spatial Geometry Statistics
(spatstat),
ensure a comprehensive coverage for most applications.
The drawbacks are the lack of a well-developed editor/debugger, scattered documentation and a cumbersome syntax.
There are a short summary of essential commands
and a list of MATLAB <-> R equivalents
(another list).
?plot # for a command
?spatstat::Kest # for a package
??command # generic search
<Ctrl> + L
to clear the console screen.
closeAllConnections()
rm(list=ls())
$ sudo add-apt-repository 'deb http://cran.ma.imperial.ac.uk/bin/linux/ubuntu xenial/'
;
$ sudo apt-get update
;
51716619E084DAB9
)
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 51716619E084DAB9
;
$ sudo apt-get install r-base
> install.packages("Rcmdr")
from within R and wait!).
$ R CMD INSTALL package_name.tar.gz -l $HOME/R-packages/
or
install.packages("package_name", lib="$HOME/R-packages/")
(more info).
source('script.R', echo=TRUE)
within R, or
$R --vanilla < script.R
from the command line.
data <- read.csv("MyDataFile.csv", sep="\t");
library(package="Hmisc")
names(data) # print headers
describe(data$variable1) # summary statistics
...
subset1 <- data[data$var1 == "yes", "var2"] # create a subset
subset2 <- data[data$var2 > 10, "var3"]
...
subset3 = subset(data, select=c(var1, var2, id)) # create a subset with
ind1 = c("var1", "id"); ind2 = c("var2", "id") # both var1 and var2
subset4 = subset( subset3, # for the same id
subset3[ind1]$id == subset3[ind2]$id,
select=c(var1,var2) )
subset5 = na.omit(subset4) # drop NA
...
mean(subset1, na.rm=TRUE) # compute mean, removing 'NA' values
sd(subset1, na.rm=TRUE) # SD
quantiles(subset1, na.rm=TRUE) # Quantiles
...
plot(subset1, subset2, col = "blue") # scatter plot
hist(subset1, col = "blue") # histogram
boxplot(data$var1, data$var2, range=0) # box plot
install.packages(“ggplot2”)
and library(package = "ggplot2")
expression()
command instead of a string. E.g.
plot( xx, yy, labx="x", laby=expression(y = sqrt(sin(x)^2)), main="..." )
.eps
, use
postscript(file='figure.eps', width=7, height=7, paper="special", horizontal=FALSE)
.
ratio <- (max(Y) - min(Y)) / (max(X) - min(X))
postscript(file="file.eps', width=7, height=7*ratio,
paper="special", horizontal=FALSE)
par(mar = c(2,2,1,1)) # trims the margins (bott,left,top,right)
par(cex = 1.1) # sets font-size-scale 110% of default
plot(X, Y, ..., asp = 1, ann=FALSE )
plot( X, Y, ..., ylim = c(max(Y), min(Y)) )
.