Mercurial > repos > public > sbplib
changeset 190:2c2ba1f3bbe3 feature/grids
Merged default into feature/grids.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 21 Mar 2016 16:33:49 +0100 |
parents | 6054dcd3c8a9 (current diff) 2ccfe80e9b58 (diff) |
children | 7c1d3fc33f90 |
files | |
diffstat | 5 files changed, 26 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
diff -r 6054dcd3c8a9 -r 2c2ba1f3bbe3 +anim/animate.m --- a/+anim/animate.m Fri Mar 04 17:20:30 2016 +0100 +++ b/+anim/animate.m Mon Mar 21 16:33:49 2016 +0100 @@ -19,6 +19,7 @@ dTau_target = 1/target_frame_rate; % Real time between frames rs = util.ReplaceableString(); + rs.appendFormat(' t: %d\n'); rs.appendFormat(' tau: %d\n'); rs.appendFormat(' target tau: %d\n'); rs.appendFormat(' Target fps: %.2f\n'); @@ -59,7 +60,7 @@ % Update information about this frame tau = toc(animation_start); - rs.updateParam(tau, targetTau, 1/dTau_target, 1/dTau, time_modifier_bound, time_modifier); + rs.updateParam(t, tau, targetTau, 1/dTau_target, 1/dTau, time_modifier_bound, time_modifier); end
diff -r 6054dcd3c8a9 -r 2c2ba1f3bbe3 +anim/setup_1d_plot.m --- a/+anim/setup_1d_plot.m Fri Mar 04 17:20:30 2016 +0100 +++ b/+anim/setup_1d_plot.m Mon Mar 21 16:33:49 2016 +0100 @@ -9,8 +9,9 @@ % be passed to functions in yfun. % plot_handles - Array of plot_handles. One for each yfun. % axis_handle - Handle to the axis plotted to. -function [update_data, plot_handles, axis_handle] = setup_1d_plot(x,yfun) +function [update_data, plot_handles, axis_handle] = setup_1d_plot(x,yfun,show_title) default_arg('yfun',{@(y)y}); + default_arg('show_title', true) if isa(yfun,'function_handle') yfun = {yfun}; @@ -24,8 +25,6 @@ axis_handle = gca; - xlabel('x') - ylabel('y') xlim([x(1) x(end)]); function update(t,varargin) @@ -33,7 +32,10 @@ for i = 1:length(yfun) set(plot_handles(i),'YData',yfun{i}(varargin{:})); end - title(axis_handle,sprintf('T=%.3f',t)); + + if show_title + title(axis_handle,sprintf('T=%.3f',t)); + end end end update_data = @update;
diff -r 6054dcd3c8a9 -r 2c2ba1f3bbe3 savepng.m --- a/savepng.m Fri Mar 04 17:20:30 2016 +0100 +++ b/savepng.m Mon Mar 21 16:33:49 2016 +0100 @@ -1,4 +1,5 @@ function savepng(h, filename, dpi) + default_arg('dpi', 300) print(h,filename,'-dpng',sprintf('-r%d',dpi)); % Let print size in inches as input parameter % Smaller boundingbox
diff -r 6054dcd3c8a9 -r 2c2ba1f3bbe3 setFontSize.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setFontSize.m Mon Mar 21 16:33:49 2016 +0100 @@ -0,0 +1,4 @@ +function setFontSize(fig, pts) + default_arg('pts', 16); + set(findall(fig,'-property','FontSize'),'FontSize',pts); +end \ No newline at end of file
diff -r 6054dcd3c8a9 -r 2c2ba1f3bbe3 toString.m --- a/toString.m Fri Mar 04 17:20:30 2016 +0100 +++ b/toString.m Mon Mar 21 16:33:49 2016 +0100 @@ -28,19 +28,26 @@ end function str = cell2string(c) - len = length(c); - - if len == 0 + if isempty(c) str = '{}'; return end + [n, m] = size(c); + str = '{'; - for i =1:len-1 - str = [str sprintf('%s, ', value2string(c{i}))]; + for i = 1:n-1 + for j = 1:m-1 + str = [str sprintf('%s, ', value2string(c{i,j}))]; + end + str = [str sprintf('%s; ', value2string(c{i,end}))]; end - str = [str sprintf('%s}', value2string(c{end}))]; + + for j = 1:m-1 + str = [str sprintf('%s, ', value2string(c{end,j}))]; + end + str = [str sprintf('%s}', value2string(c{end,end}))]; end function str = struct2string(s)