These are some MATLAB tricks I will be compiling over time.
- Use
get(0,'ScreenSize')
to get screen size, and usefigure('OuterPosition',[left bottom width height])
to set figure size and location. - Use dynamic fields name in structs instead of eval commands. Ex: Instead of
eval(['a.', 'first', '=', i])
; usestr = 'first'; a(str) = i;
- Use cells to create multi-line titles. Ex:
plot(1:10), title({'First Line','Second'})
- Use uitable to visualize some matrices. Ex: a = uitable, set(a,’data’, magic(3))
- Use isequal to compare arrays for equality.
- Use hold all to hold subsequent plots and automatically switch line color and marker styles.
- To set marker every N lines, draw three plots.
h = plot(NaN,NaN,'b-*',x,y,'b-',x2,y2,'*');
legend(h(1),'signal'); - Close all figures including GUI's with
close all hidden
. Note that if the HandleVisibility of a GUI is set to off or callback, it cannot be closed by close all only, the extra parameter 'hidden' is needed in this case.
Also, see the MATLAB questions at StackOverFlow.
No comments:
Post a Comment