is it possible to pass an array into a function?

조회 수: 15 (최근 30일)
ME
ME 2015년 4월 25일
댓글: Stephen23 2015년 4월 25일
is it possible to pass an array into a function?
  댓글 수: 1
Stephen23
Stephen23 2015년 4월 25일
Yes, because all variables are arrays in MATLAB: even scalar values are just 1x1 arrays, so there is absolutely no difference in how they get passed to functions. The only difference is if the function algorithm is written to work with them!

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

채택된 답변

Star Strider
Star Strider 2015년 4월 25일
Yes. The array is a variable, the same as a scalar, so you would simply pass it by its variable name as part of the argument list.
Example:
mtx_vct_prod = @(M,v) M*v(:);
M = rand(4); % (4x4) Matrix
v = rand(4,1); % (4x1) Vector
Mv = mtx_vct_prod(M,v);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by