User Tools

Site Tools


matlab:matlab_helpful_hacks

This is an old revision of the document!


MATLAB helpful hacks

Index Non-Empty Cells in Cell Array

startup.m

When MATLAB starts, it will look for a pathdef.m file in its startup directory.

Start up folder (in the MATLAB icon | Properties | Start in ) (e.g. D:\Sources\MATLAB) allows controlling different paths and other settings via startup.m file placed in the folder, e.g.:

disp('Welcome to physiology analysis...');
set_sources_path; % set additional paths dynamically, e.g. 
% addpath(genpath('D:\Sources\MATLAB'));
 
cd('F:\Data');
edit;
EditorMacro('Alt-Control-h', @createHeaderComment_dag);
 
dbstop if error

Exiting loop (for / while -> pause) gracefully

(i.e., without “ctrl-C” abort)

For example, when paging thru trials:

figure('Name','Plot trial','CurrentChar',' ');
for k = 1:length(trial),
...
	drawnow; pause;		
	if get(gcf,'CurrentChar')=='q', % pressing "q" will exist the loop
		break;
	end
	clf;
end
matlab/matlab_helpful_hacks.1442182344.txt.gz · Last modified: 2022/12/29 07:15 (external edit)