matlab等高线图时间深度密度

时间:2015-12-22 21:09:21

标签: matlab matlab-figure contour

我需要协助制作一个漂亮的轮廓图。我有来自水下滑翔机的数据,在这种情况下,从海洋表面反复潜水和爬升到大约30米。

我认为我的问题是内插数据,我不知道如何继续。这是我迄今为止生成的密度等值线图。

Contour plot of density

使用此代码

生成密度的等高线图
    module DisplayDriver(
    output reg [8:0] data,
     output reg en,
    output reg rs,
    output reg rw,
     output reg debug,
     input clk,
     input reset
    );

     parameter s0=0,s1=1,s2=2,s3=3,s4=4,s5=5,s6=6,s7=7,s8=8,s9=9,s10=10,normal = 11;

     reg [3:0] state; // 4 bit for max 11 combinations s0-s10 and normal
     reg [3:0] state; // 4 bit for max 11 combinations s0-s10 and normal [next State]
     reg [1:0] en_timeout; // 2 bit for en high to low to high cylce
     reg [13:0] timeout; // 14 bit 

    initial 
    // begin init
        begin
        en_timeout <= 2'b00;
        timeout <= 14'b00000000000000;
        init <= 4'b000;
        data <= 8'b00000000;
        en <= 1'b1; //active low
        rs <= 1'b0;
        rw <= 1'b0;
        state <= 4'b0000;
        next_state <= 4'b0000;

        debug <= 1'b0;
        end
     // end of init

    always @(posedge clk)
    //begin of everything that needs the clock
    begin
        if(en_timeout > 0) //begin timeout stack
            begin
            en_timeout <= en_timeout -1;
            en <= ~en;// if en_timeout = 2 -> en = 0; if en_timeout = 1 -> en = 1;
            end
        else if (timeout > 0) timeout <= timeout -1; //end timeout stack

        if(timeout == 0)state <= next_state;
    end //end of everything that needs the clock


    always @(posedge reset)
        begin
        en_timeout <= 2'b00;
        timeout <= 14'b00000000000000;
        init <= 4'b000;
        data <= 8'b00000000;
        en <= 1'b1; //active low
        rs <= 1'b0;
        rw <= 1'b0;
        state <= 4'b0000;
        next_state <= 4'b0000;

        debug <= 1'b0;
        end

    if(timeout == 0)
        begin //Begin of Initiation state machine
            case(state)
                s0:
                    begin
                    end

                s1:
                    begin
                    end
                s2:
                    begin
                    end
                s3:
                    begin
                    end
                s4:
                    begin
                    end
                s5:
                    begin
                    end
                s6:
                    begin
                    end
                s7:
                    begin
                    end
                s8:
                    begin
                    end
                s9:
                    begin
                    end
                s10:
                    begin
                    end
                normal:
                    begin
                    end
            endcase
        end //End of Initiation state machine
endmodule

我希望绘图具有平滑的轮廓线。一旦我将轮廓图看起来很好,我会将其叠加在盐度和温度散点图上。

请让我知道如何制作更好看的轮廓图。

插值是一个问题吗?或者我对数据进行网格划分的方式?

非常感谢!如果您使用过这些数据,请具体说明并提供代码示例。

以下是时间,深度和密度的matlab数据:https://www.dropbox.com/s/agi70zh7haggf07/data.mat?dl=0

1 个答案:

答案 0 :(得分:1)

问题是缺少一堆内插数据。我的意思是Z有一堆NaN s:

xlin = linspace(min(time),max(time),500);
ylin = linspace(min(depth),max(depth),500);
[X,Y] = meshgrid(xlin,ylin);
Z = griddata(time,depth,density,X,Y);
%surf(X,Y,Z) %also interesting
spy(isnan(Z));

结果:

nans in data

您的输入数据在某种程度上是不明确的,griddata放弃了。这就是原因:

>> sum(isnan(density))

ans =

        3174

修复原始数据中的NaN,您最有可能修复该情节。

更新

我扔掉了你的NaN

inds=~isnan(density);
time=time(inds);
depth=depth(inds);
density=density(inds);

看看结果如何。结果是您的原始代码已经对我好了

左边是原文,右边是de NaN版本:

original contour new contour

那么......也许你的日期时间转换已关闭?或者您的时间限制,未在原始代码中显示?

相关问题