function_handle in randomAffine3d - invalid type for 'Shear': expected numeric but function_handle instead.
1 view (last 30 days)
Show older comments
Hi all,
I'm stuck with an issue that it is driving me crazy, because I think I covered all approaches here.
I'm getting the error:
Error using randomAffine3d>iParseInputs (line209)
The value of 'Shear' is invalid. Expected Shear to be one of these types:
numeric
Instead its type was function_handle.
Error in randomAffine3d (line 114)
args = iParseInputs(varargin{:});
So I was checking my approaches
tform2 = randomAffine3d('Shear', [-4 4]) % it works
tform2.T
tform3 = randomAffine3d('Shear', @selectShear) % That's where I'm getting the error.
tform3.T
My function handle is
function numericShear = selectShear
p = 3;
shearMin = -4;
shearMax = 4;
n = 1000;
numericShear = shearMin + (shearMax - shearMin)*sum(rand(n, p, 'gpuArray'), 2)/p;
numericShear = gather(numericShear(randi(numel(numericShear))));
end
I even made
numericShear = 5; % and commented the construction for numericShear above. But that's not the problem also.
I have other functions for 'Scale' and 'Rotation' as well (and exactly the same, only changing variables obviously), and they work great.
What could be the problem?
2 Comments
Raymond Norris
on 22 Oct 2020
Hi,
This isn't my area, but looking at randomAffine3d, notice the difference between how the input args are validated for each:
function TF = validateScale(val)
if ~isa(val,'function_handle')
iValidateNumericRange('Shear',val,'positive');
end
TF = true;
end
function TF = validateShear(val)
iValidateNumericRange('Shear',val,'<',90,'>',-90);
TF = true;
end
Scale allows for a function handle. If it's not than it follows the same requirement for Shear, which requires specifically a numeric value (within a range).
Raymond
Answers (0)
See Also
Categories
Find more on Parallel Computing Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!