Surface plot mapping positive instead of negative values

Hello,
I am building a surface plot using all negative values in my Z axis. I've put in my code below along with an image of my result. The positive 600 rise on the end is confusing because none of my data is positive. The x and y coordinates are spacing coordinates. Is there a way that I'm configuring the grid that is making the Z-surface positive?
F = scatteredInterpolant(x,y,Nat);
min_x = min(x);
min_y = min(y);
max_x = max(x);
max_y = max(y);
proj_x = linspace(min_x, max_x, 100);
Proj_y = linspace(min_y,max_y,100);
[PX,PY] = ndgrid(proj_x,Proj_y);
PNat = F(PX,PY);
surf(PX,PY,PNat,'EdgeColor','none')
xlabel("Feet")
ylabel("Feet")
zlabel("(mV)")
title("Voltage Drop")
view([-33 55])
colorbar
If I need more information to explain better, please ask!
Thanks,
Evan

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 14 日
編集済み: Ameer Hamza 2020 年 11 月 14 日

1 投票

This is probably caused by scatteredInterpolant(). Beyond your data, it needs to do extrapolation, and by default, it uses linear extrapolation, which can cause issues. Try to remove the extrapolated values or use the 'nearest' extrapolation. For example, try this line
F = scatteredInterpolant(x,y,Nat,'linear','none'); % 'linear' is used for interpolation and 'none' is for extrapolation
% or
F = scatteredInterpolant(x,y,Nat,'linear','nearest');

2 件のコメント

Evan Hess
Evan Hess 2020 年 11 月 14 日
This did the trick, Thanks!
Ameer Hamza
Ameer Hamza 2020 年 11 月 15 日
I am glad to be of help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

質問済み:

2020 年 11 月 14 日

コメント済み:

2020 年 11 月 15 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by