代码之家  ›  专栏  ›  技术社区  ›  Bala

matlab中的水平标准差填充图

  •  0
  • Bala  · 技术社区  · 9 年前

    我有一个示例文件。第一列是我的y轴(表示深度)。第2列为平均值。第3列为平均值+标准差,第4列为平均-标准差。

    50      8,52021458848310    12,8530947497846    4,18733442718158
    100     19,2273240305912    23,7734814467110    14,6811666144714
    150     24,2615944638934    30,2678190187990    18,2553699089878
    200     30,6833427597963    39,4337701225571    21,9329153970354
    250     34,9509485935449    47,8249116812250    22,0769855058648
    300     32,4629780635280    40,1731214462594    24,7528346807966
    350     33,7584752483269    43,2424890071851    24,2744614894686
    400     39,6944893679358    52,5666743873288    26,8223043485428
    450     46,5051455836423    63,5570927760677    29,4531983912169
    500     49,0458418910265    70,7507807967089    27,3409029853441
    550     52,0737915678693    70,5030313767484    33,6445517589901
    600     57,5870126919132    81,1282679272898    34,0457574565365
    650     58,7946350532416    85,0428844330643    32,5463856734189
    700     59,3263566691245    92,6606340696131    25,9920792686359
    750     69,0930407230073    105,935771600040    32,2503098459742
    800     71,4416953118855    113,211405934863    29,6719846889079
    850     70,3617175991868    111,663890244861    29,0595449535130
    900     64,7764846391086    97,4995723191651    32,0533969590521
    950     70,7142864622626    102,429751242886    38,9988216816390
    1000    88,0269426788223    123,259291760572    52,7945935970724
    1250    126,529915074894    193,319779063845    59,7400510859419
    1500    173,395473019573    242,127131744655    104,663814294491
    1750    225,087445395238    300,319434885651    149,855455904824
    2000    269,218588809667    295,582291796995    242,854885822339
    figure();
    plot(example(:,2),example(:,1),'b-x','linewidth',2);
    set(gca,'ydir','rev','xlim',[0 400],'ylim',[0 2000]);
    grid on; hold on;
    fill( [example(:,3) fliplr(example(:,4))], [example(:,1) fliplr(example(:,1))], 'k'); alpha(.25);
    

    我在地块上的填充区域并没有按应有的方式显示出来。我也不确定问题出在哪里。我得到的是左边的图像,但实际上应该是右边的图像,除了填充的图像。 enter image description here

    1 回复  |  直到 9 年前
        1
  •  3
  •   rst    9 年前

    矢量的正确对齐,即将所有矢量对齐到一个大矢量。另外,你有两组向量,它们被分开看待

    [example(:,x) example(:,y)] --> [example(:,x); example(:,y)]
    

    而不是fliplr

    fliplr(example(:,x)) // --> does nothing
    flipud(example(:,x)) // --> for a column vector the correct approach
    

    工作代码示例

    %%
    example = [50      8.52021458848310    12.8530947497846    4.18733442718158
    100     19.2273240305912    23.7734814467110    14.6811666144714
    150     24.2615944638934    30.2678190187990    18.2553699089878
    200     30.6833427597963    39.4337701225571    21.9329153970354
    250     34.9509485935449    47.8249116812250    22.0769855058648
    300     32.4629780635280    40.1731214462594    24.7528346807966
    350     33.7584752483269    43.2424890071851    24.2744614894686
    400     39.6944893679358    52.5666743873288    26.8223043485428
    450     46.5051455836423    63.5570927760677    29.4531983912169
    500     49.0458418910265    70.7507807967089    27.3409029853441
    550     52.0737915678693    70.5030313767484    33.6445517589901
    600     57.5870126919132    81.1282679272898    34.0457574565365
    650     58.7946350532416    85.0428844330643    32.5463856734189
    700     59.3263566691245    92.6606340696131    25.9920792686359
    750     69.0930407230073    105.935771600040    32.2503098459742
    800     71.4416953118855    113.211405934863    29.6719846889079
    850     70.3617175991868    111.663890244861    29.0595449535130
    900     64.7764846391086    97.4995723191651    32.0533969590521
    950     70.7142864622626    102.429751242886    38.9988216816390
    1000    88.0269426788223    123.259291760572    52.7945935970724
    1250    126.529915074894    193.319779063845    59.7400510859419
    1500    173.395473019573    242.127131744655    104.663814294491
    1750    225.087445395238    300.319434885651    149.855455904824
    2000    269.218588809667    295.582291796995    242.854885822339];
    figure();
    plot(example(:,2),example(:,1),'b-x','linewidth',2);
    set(gca,'ydir','rev','xlim',[0 400],'ylim',[0 2000]);
    grid on; hold on;
    plot(example(:,4), example(:,1))
    plot(example(:,3), example(:,1))
    fill( [example(:,3); flipud(example(:,4))], [example(:,1); flipud(example(:,1))], 'k'); alpha(.25);