필터 지우기
필터 지우기

Not enough input arguments.!!!!

조회 수: 1 (최근 30일)
loukil sana
loukil sana 2016년 5월 24일
댓글: Guillaume 2016년 5월 24일
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
Guillaume
Guillaume 2016년 5월 24일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2016년 5월 24일
편집: Guillaume 2016년 5월 24일
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)

카테고리

Help CenterFile Exchange에서 Schedule Model Components에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by