Thanks
Matthew Watts
Joe
BSTeX- Equation viewer for Matlab
<http://www.geocities.com/bstex2001>
Could anyone suggest a way to do this?
Thanks,
Tim
"Joe Sababa" <joes...@yahoo.com> wrote in message
news:eeb5...@WebX.raydaftYaTP...
I've recently added a function to my Matlab toolbox for plotting wind
(or current) velocity vectors (f_vecPlot, given below). I played
around a bit adding reference vectors at positions specified by the
user (via ginput), etc. but settled on an implementation that properly
scales the data and y-axis, so a scale bar is not necessary. Note that
to use QUIVER to produce vectors that have the proper length and angle
of rotation you shouldn't use autoscaling. This and the other
functions in my toolbox are available for free download at:
http://www.rsmas.miami.edu/personal/djones/
HTH,
Dave
====================================
begin MATLAB code
====================================
function f_vecPlot(jdate,u,v,scale,offset,units);
% - plot time series of velocity vectors
%
% USAGE: f_vecPlot(jdate,u,v,scale,offset,ref,refoff)
%
% jdate = column vector of Julian dates
% u,v = corresponding vector components
% scale = plot scale (default = 1)
% offset = axis offset (default = 0)
% units = velocity units (default = none)
% (e.g., units = 'm/s')
%
% See also: f_julian, f_vecUV, f_vecMagDir, f_windCman,
% f_windstress
% ----- Notes: -----
% This function is used to plot time series of wind or
% current meter velocity vectors using the Matlab's
% QUIVER function. This function is necessary in order
% to obtain vectors that have the proper length and angle
% of rotation. An optional scaling factor can be applied
% allowing the user control over the amount of overlap among
% vectors and/or scaling of vectors relative to the overall
% time series. The Y-axis is scaled accordingly allowing
% easy, visual interpretation of vector length.
%
% U,V components of velocity vectors can be extracted from
% data specifying only Speed and Direction using f_vecUV
% ----- Author(s): -----
% by Dave Jones,<djo...@rsmas.miami.edu> Dec-2002
% http://www.rsmas.miami.edu/personal/djones/
% ----------------- DISCLAIMER: -------------------
% This code is provided as is, with no guarantees
% and is only intended for non-commercial use.
% --------------------------------------------------
% ----- Check input & set defaults: -----
if (nargin < 4), scale = 1; end; % no scaling by default
if (nargin < 5), offset = 0; end; % no offset by default
if (nargin < 6), units = []; end; % no units by default
if (scale==0)
error('You cannot scale vectors by 0');
end
if (size(u,1) ~= size(v,1)) | (size(u,1) ~= size(jdate,1))
error('U,V, and JDATE must be same size!')
end
% ---------------------------------------
nr = size(jdate,1); % # rows
figure;
hold on;
% plot vectors:
h = quiver(jdate,offset+zeros(nr,1),scale*u,scale*v,0,'.b-');
% plot base line:
plot([min(jdate) max(jdate)]',[offset offset]','k-');
% adjust aspect ratio for correct angles and lengths:
daspect(scale*[1 1 1]);
% adjust Y-axis labels:
if (scale ~= 1)
yLabels = get(gca,'yticklabel');
yLabels = num2str(str2num(yLabels)/scale);
set(gca,'yticklabel',yLabels);
end
% adjust plot appearance:
set(gcf,'color','w');
set(gca,'TickDir','out');
xlabel('Julian Date');
ylabel(units);
box off;
hold off
====================================
end MATLAB code
====================================
Susanne :-)
"Matthew Watts" <m.w...@uea.ac.uk> wrote in message news:<eeb5b...@WebX.raydaftYaTP>...
>I've recently added a function to my Matlab toolbox for plotting wind
>(or current) velocity vectors (f_vecPlot, given below).
I'm not sure if this is what the original poster had in mind, but I'll
submit this anyway.
Here's a new version of F_VECPLOT with much improved scaling (the
Y-axis is scaled instead of the X). This is now part of FATHOM, my
Matlab Toolbox for Ecological and Oceanographic Data Analysis.
Available from:
http://www.rsmas.miami.edu/personal/djones/
====================================
begin MATLAB code
====================================
function f_vecPlot(jdate,u,v,scale,units,jRange);
% - plot time series of velocity vectors
%
% USAGE: f_vecPlot(jdate,u,v,scale,units,jRange)
%
% jdate = column vector of Julian dates
% u,v = corresponding vector components
% scale = scale factor (default = 1)
% units = Y-axis label; e.g., units = 'm/s') (default = none)
% jRange = limits of dates to plot (default = auto)
% (e.g., jRange = [min max])
%
% See also: f_julian, f_vecUV, f_shadeBox
% ----- Notes: -----
% This function is used to plot time series of wind or
% current meter velocity vectors using Matlab's QUIVER
% function. This function is necessary in order to obtain
% vectors that have the proper length and angle of rotation.
% An optional scaling factor can be applied allowing the
% user control over the amount of overlap among vectors
% and/or the scaling of vectors relative to the overall
% time series. The X-axis is scaled accordingly. The Y-axis
% allows easy, visual interpretation of vector length.
%
% U,V components of velocity vectors can be extracted from
% data specifying only Speed and Direction using f_vecUV.
% ----- Author(s): -----
% by Dave Jones, Dec-2002
% http://www.rsmas.miami.edu/personal/djones/
% ----------------- DISCLAIMER: -------------------
% This code is provided as is, with no guarantees.
% --------------------------------------------------
% 10-Dec-2002: scaling now operates on the X- vs. Y-axis;
% Y-axis limits can now be specified
% ----- Check input & set defaults: -----
if (nargin < 4), scale = 1; end; % no scaling by default
if (nargin < 5), units = []; end; % no units by default
if (nargin < 6), jRange = []; end; % no range specified
if (scale==0)
error('You cannot scale vectors by 0');
end
if (size(u,1) ~= size(v,1)) | (size(u,1) ~= size(jdate,1))
error('U,V, and JDATE must be same size!')
end
% ---------------------------------------
nr = size(jdate,1); % # rows
figure;
hold on;
% plot vectors:
h = quiver(jdate/scale,zeros(nr,1),u,v,0,'.b-');
% plot base line:
plot([min(jdate/scale) max(jdate/scale)]',[0 0]','k-');
% adjust aspect ratio for correct angles and lengths:
daspect([1 1 1]);
% adjust X-axis limits & labels:
if (scale ~= 1)
if (jRange ~= [])
xlim([jRange(1)/scale jRange(2)/scale]);
end
xLabels = get(gca,'xticklabel'); % get tick labels
xLabels = str2num(xLabels); % convert to numbers
xLabels = num2str(xLabels*scale); % recale values
set(gca,'xticklabel',xLabels); % replace labels
end
% adjust plot appearance:
set(gcf,'color','w');
set(gca,'TickDir','out');
xlabel('Julian Day');