plot_four_tapers.m

来自「HERE IS A GOOD PSO TOOL BOX」· M 代码 · 共 71 行

M
71
字号
function plot_four_tapers(w1,w2,w3,w4)% Plots four different taper desings on a single graph.% Inputs:%      [w1 w2 w3 w4]: an array of taper widths%% Original code written by Lieven Vandenberghe.% Updated by Almir Mutapcic 12/2005n = size(w1,1);figure;colormap(gray);width = zeros(2*n,4);width([1:2:2*n-1],:) =  [w1 w2 w3 w4];width([2:2:2*n],:)   =  [w1 w2 w3 w4];x = zeros(2*n,1);x([1:2:2*n-1],:) = [0:n-1]';x([2:2:2*n],:)   = [1:n]';% first solutionsubplot(411)hold offplot([x;flipud(x);0], [0.5*(width(1,1)-width(:,1)); ...    flipud(0.5*(width(1,1)+width(:,1))); 0]);hold on;fill([x;flipud(x);0]', [0.5*(width(1,1)-width(:,1)); ...  flipud(0.5*(width(1,1)+width(:,1))); 0]', 0.9*ones(size([x;x;0]'))); caxis([-1,1]);plot([x;flipud(x);0], [0.5*(width(1,1)-width(:,1)); ...    flipud(0.5*(width(1,1)+width(:,1))); 0]);ylabel('width');% second solutionsubplot(412)hold offplot([x;flipud(x);0], [0.5*(width(1,2)-width(:,2)); ...    flipud(0.5*(width(1,2)+width(:,2))); 0]);hold on;fill([x;flipud(x);0]', [0.5*(width(1,2)-width(:,2)); ...   flipud(0.5*(width(1,2)+width(:,2))); 0]', 0.9*ones(size([x;x;0]'))); caxis([-1,1]);plot([x;flipud(x);0], [0.5*(width(1,2)-width(:,2)); ...    flipud(0.5*(width(1,2)+width(:,2))); 0]);ylabel('width');% third solutionsubplot(413)hold offplot([x;flipud(x);0], [0.5*(width(1,3)-width(:,3)); ...    flipud(0.5*(width(1,3)+width(:,3))); 0]);hold on;fill([x;flipud(x);0]', [0.5*(width(1,3)-width(:,3)); ...  flipud(0.5*(width(1,3)+width(:,3))); 0]', 0.9*ones(size([x;x;0]'))); caxis([-1,1]);plot([x;flipud(x);0], [0.5*(width(1,3)-width(:,3)); ...    flipud(0.5*(width(1,3)+width(:,3))); 0]);ylabel('width');% fourth solutionsubplot(414)hold offplot([x;flipud(x);0], [0.5*(width(1,4)-width(:,4)); ...    flipud(0.5*(width(1,4)+width(:,4))); 0]);hold on;fill([x;flipud(x);0]', [0.5*(width(1,4)-width(:,4)); ...   flipud(0.5*(width(1,4)+width(:,4))); 0]', 0.9*ones(size([x;x;0]'))); caxis([-1,1]);plot([x;flipud(x);0], [0.5*(width(1,4)-width(:,4)); ...    flipud(0.5*(width(1,4)+width(:,4))); 0]);ylabel('width');xlabel('segment');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?