how to solve 'ones error' in my code below

4 vues (au cours des 30 derniers jours)
BA
BA le 4 Août 2022
Réponse apportée : Voss le 4 Août 2022
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);

Réponse acceptée

Voss
Voss le 4 Août 2022
nf should be an integer.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by