我正在處理來自井的數據,有時工具不會拾取任何信號,並且該間隔將爲空= NaN。 我想在此行的區域下遮蔽,但不在沒有數據的區域。如何爲離散值下的線條陰影區域
例如: X = [1 2 3楠楠6 7] Y = [5 6 6.5楠楠6〜8]
從數據卸下NaN被不希望的。我嘗試使用填充和區域,但不起作用 任何想法?
我正在處理來自井的數據,有時工具不會拾取任何信號,並且該間隔將爲空= NaN。 我想在此行的區域下遮蔽,但不在沒有數據的區域。如何爲離散值下的線條陰影區域
例如: X = [1 2 3楠楠6 7] Y = [5 6 6.5楠楠6〜8]
從數據卸下NaN被不希望的。我嘗試使用填充和區域,但不起作用 任何想法?
我不知道內在功能的MATLAB的做與南區域的情節,但你可以遍歷的「好」的價值觀每個部分,並分別繪製他們是這樣的:
function testShade()
x=[1 2 3 NaN NaN 6 7]
y=[5 6 6.5 NaN NaN 6 8]
figure(89);
clf;
plot(x,y, '-rx', 'linewidth', 3);
hold on;
areaWithNaN(x,y);
function areaWithNaN(x,y)
badValues = isnan(x);
while(~isempty(badValues))
ind = find(badValues, 1, 'last');
% if we didn't find anything then plot everything that remains:
if isempty(ind)
ind = 0;
end
% If there are multiple bad values in a row then trim them off. This
% could be slow and optimized later:
if ind == length(badValues)
badValues= badValues(1:end-1);
continue;
end
area(x(ind+1:length(badValues)), y(ind+1:length(badValues)));
% remove the bad values we no longer care about:
badValues= badValues(1:ind-1);
end
任何插補功能將填補缺失的點。 實施例: 鑑於所述數據集:
x=1:5;
y=[11 12 NaN 15 30 NaN];
創建而不楠的數據集;
x1=x;
y1=y;
x1(isnan(y))=[];
y1(isnan(x))=[];
用插值
yNew=interp1(x1,y1,x);
這是最簡單的插值,用戶類型可以在interp1功能的幫助部分找到