how to solve 'ones error' in my code below

5 次查看(过去 30 天)
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 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by