function_handle in randomAffine3d - invalid type for 'Shear': expected numeric but function_handle instead.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Raymond Norris
2020년 10월 22일
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!