plotc.m ( File view )

  • By bole 2014-10-30
  • View(s):92
  • Download(s):2
  • Point(s): 1
			%PLOTC  plots a complex signal in 2D projection with variable projection angle.
%The angle can be modified at any time using the slider:
% slider at bottom: angle=0 the projection is the real part of the signal
% slider at 1/4: angle=pi/2 the projection is the imaginary part of the signal
% slider at top: angle=2pi same as 0
%
%Additionally, the user can choose to lock the axes or not when the angle
%is changed through the axes context menu. Note that the latter is disabled
%when tools from the figure toolbar (zoom,...) are selected.
%
% use: same as plot
%
% rem: multiple uses of plotc in the same axes are possible: it
%      produces only one slider that controls all the plots.
%
% See also
%  plot3c (another type of visualization of complex signals)
%
% G. Rilling, last modification 3.2007
% gabriel.rilling@ens-lyon.fr
function varargout = plotc(varargin)

slider_prop = 0.05;
slider_dec = 0.01;
lock_axes = 0;

% input processing
if nargin >=2 && isscalar(varargin{
1
}) && ishandle(varargin{
1
})
  ax = varargin{
1
};
  varargin = varargin(2:end);
else
  ax = gca;
end

char_inds = find(cellfun(@ischar,varargin));
if ~isempty(char_inds)
  numeric_args = char_inds(1)-1;
else
  numeric_args = length(varargin);
end

switch numeric_args
  case 1
    y = varargin{
1
};
    if isvector(y)
      x = 1:length(y);
      y = y(:);
    else
      x = 1:size(y,1);
    end
  case 2
    y = varargin{
2
};
    x = varargin{
1
};
end
args = varargin(numeric_args+1:end);

fig = ancestor(ax,'Figure');

% context menu and slider
cmenu = get(ax,'UIContextMenu');
if isempty(cmenu)
  cmenu = uicontextmenu;
  set(ax,'UIContextMenu',cmenu);
end
if ~hastag(ax,'complexplot')
  lock_axes_menu_item = uimenu(cmenu,'Label','Lock axes','Callback',@togglelock);
  P = get(ax,'Position');
  slider = uicontrol('Style','Slider','Min',0,'Max',1,'Value',0,'SliderStep',[.01,.05],'Units','normalized','Position',[P(1)+P(3)+P(3)*slider_dec,P(2),P(3)*slider_prop,P(4)],'Callback',@slider_callback);
  addtag(slider,'complexplotslider')
else
  slider = findtag(fig,'complexplotslider');
end

% setup the complex plot
phi = get_axes_phase;
obj = plot(ax,x,real(exp(-i*phi)*y),args{
:
});
addtag(ax,'complexplot') % needs to be after the plot command in case the latter redefines the Tag property of the axes (default behavior)
addtag(obj,'complex');
arrayfun(@(x)setappdata(obj(x),'complex_data',y(:,x)),1:length(obj));
set(obj,'UIContextMenu',cmenu);
if nargout
  varargout = {
obj
};
end

set(fig,'toolbar','figure');

  function show_phase(phi)
    Xl = get(ax,'Xlim');
    Yl = get(ax,'Ylim');
    ax_ch = findtag(ax,'complex');
    for child = ax_ch'
      z = getappdata(child,'complex_data');
      z = real(exp(-i*phi)*z);
      set(child,'YData',z);
    end
    set(ax,'Xlim',Xl);
    if ~lock_axes
      set(ax,'YlimMode','auto');
    else
      set(ax,'Ylim',Yl);
    end
    drawnow;
  end

  function slider_callback(varargin)
    show_phase(get_axes_phase());
  end

  function phi = get_axes_phase()
    v = get(slider,'Value');
    phi = 2*pi*v;
  end

  function togglelock(varargin)
    lock_axes = ~lock_axes;
    if lock_axes
      set(lock_axes_menu_item,'Checked','on');
    else
      set(lock_axes_menu_item,'Checked','off');
    end
  end

end
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
bugfix.sh216.00 B27-06-07 22:12
cemdc.m2.30 kB27-06-07 22:12
cemdc2.m2.31 kB27-06-07 22:12
cemdc2_fix.m2.26 kB27-06-07 22:12
cemdc_fix.m2.25 kB27-06-07 22:12
emd.m21.75 kB27-06-07 22:12
emdc.m2.23 kB27-06-07 22:12
emdc_fix.m2.09 kB27-06-07 22:12
emd_local.m9.67 kB27-06-07 22:12
emd_online.m25.70 kB27-06-07 22:12
make_emdc.m1.33 kB27-06-07 22:12
cemdc.c4.85 kB27-06-07 22:12
cemdc2.c4.87 kB27-06-07 22:12
cemdc2_fix.c4.11 kB27-06-07 22:12
cemdc_fix.c4.13 kB27-06-07 22:12
cextr.c14.37 kB27-06-07 22:12
cextr.h770.00 B27-06-07 22:12
cio.c7.38 kB27-06-07 22:12
cio.h1.16 kB27-06-07 22:12
cio_fix.c6.77 kB27-06-07 22:12
cio_fix.h1.09 kB27-06-07 22:12
clocal_mean.c4.97 kB27-06-07 22:12
clocal_mean.h790.00 B27-06-07 22:12
clocal_mean2.c4.79 kB27-06-07 22:12
clocal_mean2.h752.00 B27-06-07 22:12
emdc.c4.60 kB27-06-07 22:12
emdc_fix.c3.43 kB27-06-07 22:12
emd_complex.c508.00 B27-06-07 22:12
emd_complex.h512.00 B27-06-07 22:12
extr.c10.23 kB27-06-07 22:12
extr.h674.00 B27-06-07 22:12
interpolation.c2.06 kB27-06-07 22:12
interpolation.h468.00 B27-06-07 22:12
io.c6.86 kB27-06-07 22:12
io.h1.14 kB27-06-07 22:12
io_fix.c6.04 kB27-06-07 22:12
io_fix.h1.07 kB27-06-07 22:12
local_mean.c2.77 kB27-06-07 22:12
local_mean.h710.00 B27-06-07 22:12
emd_fmsin.m1.82 kB27-06-07 22:12
emd_sampling.m896.00 B27-06-07 22:12
emd_separation.m1.30 kB27-06-07 22:12
emd_triang.m704.00 B27-06-07 22:12
ex_online.m2.02 kB27-06-07 22:12
triangular_signal.m378.00 B27-06-07 22:12
bivariate_EMD_illustration.m1.25 kB27-06-07 22:12
bivariate_EMD_mean_definitions.m2.91 kB27-06-07 22:12
bivariate_EMD_principle.m3.84 kB27-06-07 22:12
dirstretch.m614.00 B27-06-07 22:12
float_position_record.mat8.34 kB27-06-07 22:12
index_emd.m4.38 kB27-06-07 22:12
install_emd.m1.53 kB27-06-07 22:12
ls-R1,004.00 B27-06-07 22:12
revert_bugfix.sh216.00 B27-06-07 22:12
uninstall_emd.m2.08 kB27-06-07 22:12
addtag.m791.00 B27-06-07 22:12
boundary_conditions_emd.m3.46 kB27-06-07 22:12
cemd_disp.m2.49 kB27-06-07 22:12
cemd_visu.m2.76 kB27-06-07 22:12
cenvelope.m2.00 kB27-06-07 22:12
dirstretch.m1.22 kB27-06-07 22:12
disp_hhs.m1.55 kB13-09-14 22:55
emd_visu.m3.14 kB27-06-07 22:12
extr.m1.89 kB27-06-07 22:12
findtag.m1.02 kB27-06-07 22:12
hastag.m659.00 B27-06-07 22:12
hhspectrum.m1.41 kB27-06-07 22:12
io.m504.00 B27-06-07 22:12
plot3c.m798.00 B27-06-07 22:12
plotc.m3.17 kB27-06-07 22:12
rmtag.m820.00 B27-06-07 22:12
toimage.m2.93 kB27-06-07 22:12
<src>0.00 B29-10-14 13:58
<NSIP2003>0.00 B29-10-14 13:58
<SPL2007>0.00 B29-10-14 13:58
<EMDs>0.00 B29-10-14 13:58
<examples>0.00 B29-10-14 13:58
<utils>0.00 B29-10-14 13:58
<package_emd>0.00 B29-10-14 13:58
...
Sponsored links

plotc.m (91.07 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D