如何在matlab中绘制分析图

How to plot an analysis picture in matlab

我想在 MATLAB 中绘制这样的图:

我在 google 中进行了搜索,但没有找到在 MATLAB 中执行此操作的方法。
我怎样才能在 MATLAB 中做这个数字?不需要完全相同的情节,但情节中必须涉及相同的信息。 谢谢

如评论中所述,最好在其他程序中执行此操作(会更容易、更美观)。但是,如果您确实需要在 Matlab 中这样做,那么像这样的东西就可以做到。

% Create figure and axes
f = figure(1); clf
a = axes;
aPos = [0.1 0.1 0.03 0.8];
gbColor = [0 1 0.7];
yTick = logspace(4,10,7);
YTickLlb = {'0.01Mz','0.1 MHz','1.0 MHz','10 MHz','100 MHz','1 GHz',''};
set(a,...
    'Position', aPos, ...
    'YAxisLocation','right', ...
    'YLim', yTick([1 end]), ...
    'YScale','log',...
    'YTickLabel',YTickLlb,...
    'XTick',[], ...
    'Box','on',...
    'Color', gbColor)
title('Frequency')

% Plot text
txtFontSize = 12;
txt = {'Hearing threshold (20 kHz)','Therapeutic applications','Medical imaging','Ultrasound microscopy'};
txtPos = [2e4 1e6 2e7 1e9];
txtOffset = 5;
for k = 1:length(txt)
    t(k) = text(txtOffset, txtPos(k), txt{k},'FontSize', txtFontSize);
end

% Plot arrows (with figure as reference)
arrowPos = {[6 70]*1e6, [7 70]*1e8};
arrowType = {'doublearrow', 'arrow'};
arrowOffset = (aPos(1) + aPos(3)*txtOffset*0.9)*[1 1];
normYTick = linspace(0,1,length(yTick));
for k = 1:length(arrowPos)
    annotation(f, arrowType{k}, arrowOffset, interp1(yTick, normYTick, arrowPos{k})*aPos(4) + aPos(2),...
        'HeadStyle','Plain','HeadWidth',4, 'HeadLength', 4);
end

% Plot information text
text(7, yTick(end), '\lambda f = 1500 ms^{-1} in water','FontSize', txtFontSize)

评论太长了,所以这是@nilZ0r 答案的固定(无循环)版本(如果你要接受任何答案,请接受他的 ).我注释了更改:

% Create figure and axes
f = figure('Color',[1 1 1]); clf % <-- white background
a = axes;
aPos = [0.1 0.1 0.03 0.8];
gbColor = [0 1 0.7];
yTick = logspace(4,10,7);
YTickLlb = {'0.01MHz','0.1 MHz','1.0 MHz','10 MHz','100 MHz','1 GHz',''};
set(a,...
    'Position', aPos, ...
    'YAxisLocation','right', ...
    'YLim', yTick([1 end]), ...
    'YScale','log',...
    'YTickLabel',YTickLlb,...
    'XTick',[], ...
    'Box','on',...
    'Color', gbColor)
title('Frequency')

% Plot text
txtFontSize = 12;
txt = {'Hearing threshold (20 kHz)','Therapeutic applications',...
    'Medical imaging','Ultrasound microscopy'};
txtPos = [2e4 1e6 2e7 1e9];
txtOffset = 5;
% No need for a loop:
text(ones(numel(txtPos),1)*txtOffset, txtPos, txt,'FontSize', txtFontSize);

% Plot arrows (with figure as reference)
arrowPos = [[6 70]*1e6; [7 70]*1e8]; % <-- matrix instead of a cell array
% arrowType is deleted
arrowOffset = (aPos(1) + aPos(3)*txtOffset*0.9)*[1 1];
normYTick = linspace(0,1,length(yTick));
% two different calls to 'annotation', based on the arrow type:
annotation(f, 'doublearrow', arrowOffset, interp1(yTick, normYTick,...
    arrowPos(1,:))*aPos(4) + aPos(2),'HeadStyle','Plain','Head1Width',4,...
    'Head2Width',4, 'Head1Length', 4,'Head2Length', 4);
annotation(f, 'arrow', arrowOffset, interp1(yTick, normYTick,...
    arrowPos(2,:))*aPos(4) + aPos(2),'HeadStyle','Plain','HeadWidth',4,...
    'HeadLength',4);

% Plot information text
text(7, yTick(end), '\lambda f = 1500 ms^{-1} in water',...
    'FontSize', txtFontSize)

结果: