TriScatteredInterp on scattered dataset with duplicates

조회 수: 1 (최근 30일)
Rui
Rui 2012년 7월 11일
I am facing a problem that is driving me crazy and I hope that someone will be able to help me...
According to the MATLAB documentation, applying the TriScatteredInterp function on a scattered dataset with duplicates will implicitly remove the duplicates and average the associated data values. Now consider the simple test code
clear all;
% Create x- and y-coordinates of three random points in the 2D plane
X = rand(3,2);
% Duplicate all three points
X = [X;X];
% Assign value 100 to original points and value 0 to duplicates
V = [100*ones(3,1);zeros(3,1)];
% Merge points and values into one matrix
A = [X V];
% ! Critical line !
% A = sortrows(A);
% Construct interpolant
% Duplicates should be removed and associated values should be averaged to 50
F = TriScatteredInterp(A(:,1:2),A(:,3));
% Output values
F.V
In this form, the output is
ans =
50
50
50
as expected. However, upon uncommenting of the critical code line with the sortrows command, the output becomes
ans =
50
100
50
and something is wrong. I believe that the order of the scattered data (and hence the critical code line) should not play any role, should it? What's going on here? I am using MATLAB R2010a.
Any help is appreciated.
Rui

답변 (2개)

Jonas
Jonas 2012년 7월 11일
Er... I obtain the 50-50-50 in both cases...
  댓글 수: 1
Jonas
Jonas 2012년 7월 11일
But I have this warning, in fact: "Warning: Duplicate data points have been detected and removed - corresponding values have been averaged. " In both cases. I have the 2012a version. Maybe this bug has been corrected between your Matlab version and my one?

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


Rui
Rui 2012년 7월 11일
Hi Jonas,
Many thanks for having a look at my issue. I appreciate it.
It's strange though that you couldn't reproduce the problem. I get the same warning message, which would be fine if the averaging was done correctly (but in my case it's not). It seems that this is indeed related to the different MATLAB versions. Unfortunately I don't have access to newer versions of MATLAB, so I can't confirm myself whether that's true or not.
Anyway, I will then remove the duplicates and carry out the averaging manually. Any further comments are still appreciated.
Rui

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by