Vector inputs in functions
조회 수: 1 (최근 30일)
이전 댓글 표시
I need to put a vector input into a function and then use repmat to repeat each element a certain number of times. I have my input as repvec = (x,w), where x is the vector and w is the number of times to repeat it. I keep getting an error that says repvec is undefined. This is my code:
function vec = repvecR2(x,w)
n = length(x)
vec = repmat(w,1:n)
end
댓글 수: 0
답변 (1개)
Walter Roberson
2015년 9월 23일
You called your function repvecR2 but you are trying to invoke repvec without the R2
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!