How to create 3D grid from data without interpolation?

Hey,
is there some function like griddata which doesnt interpolate the z data? I need some function to save all z values or the mean in the specific x,y segment.
Thanks for you help!

댓글 수: 10

José-Luis
José-Luis 2016년 7월 4일
편집: José-Luis 2016년 7월 4일
If you don't interpolate, then how do you get the data? Taking the mean is pretty much a linear interpolation, if I understood what you meant correctly.
I have x,y,z datapoints and would like to sort them in x,y segments. So the function i'm looking for could save all the z datapoints in the x,y segments or just their mean value.
wkm42
wkm42 2016년 7월 4일
편집: wkm42 2016년 7월 4일
For example:
Datapoints:
x: torque = [12,13,20,30]
y: speed = [512,800,1300,1506]
z: z = [2,2,1,4]
Intervalls of my desired grid:
torque_intervall = [10,20,30]
speed_intervall = [500,1000,1500,2000]
The function im looking for:
output = gridfunc(torque,speed,z,torque_intervall,speed_intervall)
output(torque=10..20,speed=500..1000)= [z(1),z(2)]
or
output(torque=10..20,speed=500..1000)= mean([z(1),z(2)])
Sorry, I don't get it.
How do you define your brackets?
What is the result you expect? Why [2,2]?
I edited my example above and hope its reasonable now ;)
Your suggestion 'linear interpolation' is kinda what I'm looking for, but still griddata interpolates outside of the datapoints and misses some of the datapoints inside the grid..
That still looks like interpolation to me. It looks like you might want to find the nearest neighbor.
wkm42
wkm42 2016년 7월 4일
편집: wkm42 2016년 7월 4일
Still 'griddata' interpolates when there are no datapoints, but doesn't when there are..
Then don't use griddata().
interp2() might provide what you need.
Did you actually look at the nearest neighbor solution I previously suggested?
Yes, but nearest neighbor doesnt seem to be a solution..
interp2(): If X and Y are grid vectors, then V must be a matrix containing length(Y) rows and length(X) columns.
I just got z as a vector
I'm sorry: I don't quite get what you are after. Maybe try the 'nearest' option for griddata()?

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

답변 (1개)

Radu Trimbitas
Radu Trimbitas 2016년 7월 4일

0 개 추천

interp2() has options for cubic or spline

카테고리

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

제품

질문:

2016년 7월 4일

댓글:

2016년 7월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by