Borrar filtros
Borrar filtros

Not enough input arguments.!!!!

1 visualización (últimos 30 días)
loukil sana
loukil sana el 24 de Mayo de 2016
Comentada: Guillaume el 24 de Mayo de 2016
hi, when i exécute this function an error message appears: Error using get_block (line 9) Not enough input arguments.!!!!!!
function block = get_block( Mat1, block_number )
% returns block of matrix
% 1: Mat2(1:2,1:3)
% 2: Mat2(1:2,4:6)
% 3: Mat2(3:4,1:3)
% 4: Mat2(3:4,4:6)
%
switch block_number
case 1
block = Mat1(1:2,1:3);
case 2
block = Mat1(1:2,4:6);
case 3
block = Mat1(3:4,1:3);
case 4
block = Mat1(3:4,4:6);
otherwise
error('Matrix only has 4 blocks')
end
end
  1 comentario
Guillaume
Guillaume el 24 de Mayo de 2016
Note that another implementation of your function would be:
function block = get_block(Mat1, block_number)
assert(size(Mat1) == [4, 6], 'Invalid matrix size');
blocks = mat2cell(Mat1, [2 2], [3 3])'; %split matrix into blocks and transpose since indexing is row major
block = blocks(block_number);
end

Iniciar sesión para comentar.

Respuestas (1)

Guillaume
Guillaume el 24 de Mayo de 2016
Editada: Guillaume el 24 de Mayo de 2016
The problem is with the way you call the function, not with the code of the function. You need to pass two arguments to the function when you call it, e.g:
m = reshape(1:24, 4, 6); %demo matrix
block = get_block(m, 3)

Categorías

Más información sobre Schedule Model Components en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by