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일
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

This did the trick, Thanks!
I am glad to be of help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

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