Error: "Not enough input arguments"

조회 수: 1 (최근 30일)
Anne Nguyen
Anne Nguyen 2019년 10월 4일
답변: Walter Roberson 2019년 10월 4일
Here is the code that I have written so far:
function out = repvec(vec, s)
vec_size = size(vec);
num_row = vec_size(1);
num_col = vec_size(2);
if num_col == 1
vec = vec';
end
out_vec = [];
if s == 0
out = []
elseif num_row == 0
out = []
else
for i = length(vec)
for j = 1:s
out_vec = [out_vec, vec(i)]
end
end
end
out = out_vec;
end
I am getting the error tha
t there are not enough input arguments, and an error in the line with vec_size = size(vec). I am fairly new to MATLAB, so any help would be appreciated!

답변 (1개)

Walter Roberson
Walter Roberson 2019년 10월 4일
You cannot invoke that code by just pressing the green Run button. You need to either call it from a function or script, or else you need to go to the command line and invoke it, passing in apropriate data.
For example:
repvec( sprintf('bottles of beer on the wall\n'), 99)

카테고리

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