Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
alta
alta
Commits
39f7f4a7
Commit
39f7f4a7
authored
Nov 05, 2013
by
Laurent Belcour
Browse files
Fixing the Matlab interpolator to handle domain boundary.
parent
f519aa73
Changes
1
Hide whitespace changes
Inline
Side-by-side
sources/plugins/data_interpolant_matlab/data.cpp
View file @
39f7f4a7
...
...
@@ -123,7 +123,7 @@ vec data_interpolant::value(vec ax) const
// Evaluate the matlab routine
std
::
stringstream
cmd
;
cmd
<<
"y = griddatan(X(:, 1:"
<<
dimX
()
<<
"), Y(:, 1), x);"
;
cmd
<<
"y = griddatan(X(:, 1:"
<<
dimX
()
<<
"), Y(:, 1), x
, 'linear'
);"
;
engEvalString
(
ep
,
cmd
.
str
().
c_str
());
// Get results and copy it
...
...
@@ -131,6 +131,21 @@ vec data_interpolant::value(vec ax) const
double
*
y_val
=
(
double
*
)
mxGetData
(
y
);
memcpy
(
&
res
[
0
],
y_val
,
dimY
()
*
sizeof
(
double
));
// Fail safe: if the query point is outside of the convex hull of the
// data, rerun the algorithm using a nearest option.
if
(
isnan
(
res
[
0
]))
{
cmd
.
str
(
std
::
string
());
cmd
<<
"y = griddatan(X(:, 1:"
<<
dimX
()
<<
"), Y(:, 1), x, 'nearest');"
;
engEvalString
(
ep
,
cmd
.
str
().
c_str
());
// Get results and copy it
y
=
engGetVariable
(
ep
,
"y"
)
;
double
*
y_val
=
(
double
*
)
mxGetData
(
y
);
memcpy
(
&
res
[
0
],
y_val
,
dimY
()
*
sizeof
(
double
));
}
return
res
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment