matlab:matlab_helpful_hacks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
matlab:matlab_helpful_hacks [2015/08/11 15:32] – igorkagan | matlab:matlab_helpful_hacks [2018/11/01 06:03] – igorkagan | ||
---|---|---|---|
Line 12: | Line 12: | ||
==== startup.m ==== | ==== startup.m ==== | ||
- | When MATLAB starts, it looks for a pathdef.m file in its startup directory. | + | When MATLAB starts, it will look for a **pathdef.m** file in its startup directory. |
- | Start up folder (in the icon | Properties | Start in ) (e.g. D: | + | Start up folder (in the MATLAB |
<code matlab> | <code matlab> | ||
disp(' | disp(' | ||
set_sources_path; | set_sources_path; | ||
- | % p = genpath(' | + | % addpath(genpath(' |
cd(' | cd(' | ||
Line 28: | Line 28: | ||
</ | </ | ||
+ | ==== Exiting loop (for / while -> pause) gracefully ==== | ||
+ | (i.e., without " | ||
+ | |||
+ | For example, when paging thru trials: | ||
+ | <code matlab> | ||
+ | figure(' | ||
+ | for k = 1: | ||
+ | ... | ||
+ | drawnow; pause; | ||
+ | if get(gcf,' | ||
+ | break; | ||
+ | end | ||
+ | clf; | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Finding indices between two vectors of start and end indices, using arrayfun ==== | ||
+ | |||
+ | Assume we have two vectors, repeated_segments_start_idx, | ||
+ | |||
+ | <code matlab> | ||
+ | idx = [repeated_segments_start_idx(segments2remove_idx): | ||
+ | |||
+ | idx = cell2mat(arrayfun(@colon, | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Maximize figure window ==== | ||
+ | <code matlab> | ||
+ | |||
+ | |||
+ | |||
+ | ==== Plot an '' | ||
+ | |||
+ | <code matlab> | ||
+ | h = imagesc(X, | ||
+ | set(h,' | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Shifting colormaps ==== | ||
+ | Sometimes the colormap plots are shifted after printing. To fix this: | ||
+ | - in Adobe Illustrator, | ||
+ | |||
+ | You have to do it for each of the colormaps. | ||
matlab/matlab_helpful_hacks.txt · Last modified: 2022/12/29 07:15 by 127.0.0.1