griddedInterpolant bug with Matlab Coder in R2022b

4 vues (au cours des 30 derniers jours)
Sri Raman A
Sri Raman A le 10 Nov 2022
Modifié(e) : Thomas Best le 8 Août 2023
Hi All,
I am trying to make use MATLAB Coder (version 5.5) for griddedInterpolant, But I am getting the following errors
"??? Sample points must be 1-dimensional for code generation."
clearvars; clc; close all;
x = -5:0.8:5;
y = -5:0.8:5;
[xg,yg] = ndgrid(x,y);
vg = sin(xg.^2 + yg.^2) ./ (xg.^2 + yg.^2);
surf(xg,yg,vg); hold on
xq = -4;
yq = 1.2;
vq = griddedInterpolant_test(x,y,xq,yq);
plot3(xq,yq,vq,'r*');
codegen -report -config:lib griddedInterpolant_test.m -args {-5:0.8:5, -5:0.8:5, -4, 1.2}
In my original code, I also get the following error even though xg, yz, zg matrices in griddedInterpolant(xg,yg,zg) are all having a fixed (m x n) size and when the interpolant is evaluated at a single xq, yq.
"??? Unable to determine varargin/varargout index due to failed loop unrolling."
Does it mean that MATLAB Coder is not compatible with 2-dimensional interpolation when griddedInterpolant is used ?
Please write to me if you need any additional details
  1 commentaire
Sri Raman A
Sri Raman A le 10 Nov 2022
vg is generated inside the griddedInterpolant_test function based on the same xg and yg. It is additionally generated in the script only for plotting the surface (because visualizing the problem makes it easy to understand)

Connectez-vous pour commenter.

Réponse acceptée

Thomas Best
Thomas Best le 8 Août 2023
Modifié(e) : Thomas Best le 8 Août 2023
I had the same error - updating to R2023a fixed it for anyone else running into the same problem.

Plus de réponses (1)

Steven Lord
Steven Lord le 10 Nov 2022
The first error you received is not a bug. The fact that griddedInterpolant requires that the sample points be vectors rather than matrices or N-dimensional arrays when used in code generation with MATLAB Coder is a documented limitation. See the "C/C++ Code Generation" item in the Extended Capabilities section of the documentation page to which I linked above.
I am not certain of the reason you received the second error message you quoted. From the fact that you said you received this with "my original code" I assume that you ran a different code than the one you posted to receive that error. Without seeing that code I'm not sure if it would be possible to determine the cause of this error.
  16 commentaires
Sri Raman A
Sri Raman A le 16 Nov 2022
For those who are interested, Here is the reply (for case number 05848451) from MATLAB Technical support on this.
"griddedInterpolant supports only 1D inputs for code generation as of R2022b, we'll enable support for 2D and nD inputs only in the next release.
Enabling 2D inputs requires significant changes, that can't be implemented in R2022b"
And they have set the current status of my case to Bug/Enhancement Submitted
Walter Roberson
Walter Roberson le 17 Nov 2022
If you are commenting in the Answers section for a technical query - then I expect the answers to be technical and leading to a solution for the problem I have posted. In short I expect bulls-eye kind of technical answers
Well, that certainly might be what you expect but it is not what this resource was created for.
This MATLAB Answers resource was created for members of the public to ask other members of the public for assistance with Mathworks related topics. It is not an official support forum from Mathworks, and any Mathworks employees who respond here do so as volunteers (with the exception of people running the facility itself.)
Experts in a specialized topic might not happen to see any particular question -- there are between 100 and 200 new Questions per day, and discussion on more than 200 different topics per day even during slow times -- and topic experts are often busy doing other thing.
It is normal and expected here, an inherent part of why the facility was set up, that responses from volunteers might be along the lines of "I don't know for sure, but let us work together to see if we can come up with some solution together."
It also happens a lot of the time that people asking questions do not explain well, or that people turn out to be asking about something different than what they actually need, so it is common that the volunteers end up asking a bunch of questions in order to figure out what is really needed and to figure out what is happening (and try to figure out why, and what the work-arounds might be.)
A lot of the people who ask questions do not have English as their native language, and a fair number of the volunteers do not have English as their native language, so there are also translation issues, and differences in how terms are to be intepreted.
The purpose of the facility is for people doing their best to help other people, not questions to only be responded to by topic specialists who already know the answer or can definitely find out (such as by having access to internal source code.)

Connectez-vous pour commenter.

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by