how to solve 'ones error' in my code below

조회 수: 2 (최근 30일)
BA
BA 2022년 8월 4일
답변: Voss 2022년 8월 4일
Error using ones
Size inputs must be integers.
Error in matlab.internal.builtinhelper.repmat (line 59)
B = A(ones(siz,'int8'));
Error in inspect_rtmri (line 1097)
vid_rs = repmat(struct('cdata', [], 'colormap', []), 1, nf);
##### here is the code####
if nargin <= 2
M = varargin{1};
checkSizesType(M);
if isscalar(M)
siz = [M M];
elseif ~isempty(M) && isrow(M)
siz = M;
else
error(message('MATLAB:repmat:invalidReplications'));
end
siz = double(full(siz));
else % nargin > 2
siz = zeros(1,nargin-1);
for idx = 1:nargin-1
arg = varargin{idx};
if isscalar(arg)
siz(idx) = double(full(checkSizesType(arg)));
else
error(message('MATLAB:repmat:invalidReplications'));
end
end
end
if isscalar(A) && ~isobject(A)
B = A(ones(siz,'int8')); ###### the error comes from here
elseif ismatrix(A) && numel(siz) == 2
[m,n] = size(A);

채택된 답변

Voss
Voss 2022년 8월 4일
nf should be an integer.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by