matlab画余流或流速的时序图【图来自粉丝】

文摘   2024-12-09 18:10   德国  
matlab画余流或流速的时序图【图来自粉丝】

粉丝的图
我重复的图:
不够完美!能先凑合着用着,后续再看看如何更新。
主程序:
.rtcContent { padding: 30px; } .lineNode {font-size: 12pt; font-family: "Times New Roman", Menlo, Monaco, Consolas, "Courier New", monospace; font-style: normal; font-weight: normal; }% current_ timeseriesclear;clc;close all;% 由于没有实际数据,流场构造,% 首先流场特性,有大小有方向的矢量数据;% 因此time   = -pi/2:pi/20:2*pi;u1 =(5*sin(time));v1 = (5*cos(time));% 画图close allh=figure;set(gcf,'position',[50 50 1200 650],'color','w')axes('Position',[0.05 0.05 0.85 0.8])axis offM = 6;k=6;height=0.15;for i = 1:M    axes('position',[0.05 0.05+(i-1)*height 0.85 height]);    f=feather(u1,v1,'-k');    N = length(u1);    for ii = 1:N        f(ii).LineWidth = 1.5;    end    xlim([-5 length(u1)+1])    if i>1        set(gca,'xtick',[1:5:length(u1)],'xticklabel',[],'xcolor','w')        box off    end    if i ==1        set(gca,'xtick',[1:5:length(u1)],'xticklabel',{'1日', '4日','8日', '12日','16日', '18日', '22日', '24日','26日', '28日', '30日'})        box off        xlabel('时间','fontsize',15,'FontWeight','bold')    end    str_y = {'表层','0.2H','0.4H','0.6H','0.8H','底层'};    set(gca,'ytick',0,'yticklabel',str_y(k),'fontsize',15,'FontWeight','bold')    k = k-1;    grid on     % 添加网格线    ax = gca;   % 将当前坐标区实例化    ax.GridLineStyle = '--';    % 设置网格线样式    ax.GridColor = [0,0,0];   % 设置颜色    ax.GridAlpha = 1; % 设置透明度endtitle('余流分布图','fontsize',15,'FontWeight','bold')box off     % 取消边框ax1 = axes('Position',get(gca,'Position'),'XAxisLocation','top',...    'YAxisLocation','right','Color','none','XColor','k','YColor','k');  % 设置坐标区set(ax1,'XTick', [],'YTick', []);   % 去掉xy轴刻度hold offexport_fig('feather.jpg')

函数:
.rtcContent { padding: 30px; } .lineNode {font-size: 12pt; font-family: "Times New Roman", Menlo, Monaco, Consolas, "Courier New", monospace; font-style: normal; font-weight: normal; }function hh = feather(varargin)%FEATHER Feather plot.%   FEATHER(U,V) plots the velocity vectors with components U and V as%   arrows emanating from equally spaced points along a horizontal axis.%   FEATHER is useful for displaying direction and magnitude data that%   is collected along a path.%%   FEATHER(Z) for complex Z is the same as FEATHER(REAL(Z),IMAG(Z)).%   FEATHER(...,'LineSpec') uses the color and linestyle specification%   from 'LineSpec' (see PLOT for possibilities).%%   FEATHER(AX,...) plots into AX instead of GCA.%%   H = FEATHER(...) returns a vector of line handles.%%   Example:%      theta = (-90:10:90)*pi/180; r = 2*ones(size(theta));%      [u,v] = pol2cart(theta,r);%      feather(u,v), axis equal%%   See also COMPASS, ROSE, QUIVER.%   Charles R. Denham, MathWorks 3-20-89%   Copyright 1984-2017 MathWorks, Inc.if nargin > 0    [varargin{:}] = convertStringsToChars(varargin{:});end% Parse possible Axes input[cax, args, nargs] = axescheck(varargin{:});if nargs < 1    error(message('MATLAB:narginchk:notEnoughInputs'));elseif nargs > 3    error(message('MATLAB:narginchk:tooManyInputs'));endif nargs > 0    x = args{1};endif nargs > 1    y = args{2};endif nargs > 2    s = args{3};endif ischar(x)    error(message('MATLAB:feather:FirstNumericInput'));endxx = [0 1 NaN .8 1 .8]';yy = [0 0 NaN .08 0 -.08].';arrow = xx + yy .* sqrt(-1);if nargs == 2    if ischar(y)        s = y;        x = matlab.graphics.chart.internal.datachk(x);        y = imag(x);        x = real(x);    else        s = '-';    endelseif nargs == 1    s = '-';    x = matlab.graphics.chart.internal.datachk(x);    y = imag(x);    x = real(x);endif ischar(x) || ischar(y)    error(message('MATLAB:feather:LeadingNumericInputs'))endx = matlab.graphics.chart.internal.datachk(x);y = matlab.graphics.chart.internal.datachk(y);[st, co, mark, msg] = colstyle(s);error(msg);x = x(:);y = y(:);if length(x) ~= length(y)    error(message('MATLAB:feather:LengthMismatch'));endm = size(x, 1);z = (x + y .* sqrt(-1)).';a = arrow * z + ones(6, 1) * (1:m);% Create plotif isempty(cax) || ishghandle(cax, 'axes')    cax = newplot(cax);    parax = cax;else    parax = cax;    cax = ancestor(cax, 'axes');endh = plot(real(a), imag(a), [st co mark], ...    'parent', parax);% h = plot(real(a), imag(a), [st co mark], [1 m], [0 0], [st co mark], ...%     'parent', parax);if isempty(co)    co = get(cax, 'colororder');    set(h, 'color', co(1,:))endif nargout > 0    hh = h;endend

海洋与大气科学
海洋与大气科学数据分析,数据可视化分享,可教学。
 最新文章