- "not enough input arguments": your function has 1 argument so you have to call it with 1 input. For example build_links(x), where x is something you defined earlier
- cell(1,size(...))) will give error. You want to make a cell(size(x))
Creating empty cell array with function
3 ビュー (過去 30 日間)
古いコメントを表示
function link_set = build_links(link_vectors);
% Use the 'cell' 'and 'size' commands to create an empty cell array the
% same size as link_vectors, named 'link_set'
link_set = cell(1,size(link_vectors));
I am working on a project in MATLAB Grader and it has been a while since iv'e used MATLAB. I'm having trouble creating this array and I keep getting the "Not enough input arguments." error. Any help or guidamce would be greatly appreciated.
3 件のコメント
AndresVar
2022 年 3 月 1 日
I see, well here is an example, for n=2, m=3. This function just creates a cell array the same size as the input, which is the first part of what your function should do.
anInput = {[1;2;3],[4;5;6]}; % variable to use as an input
size(anInput)
anOutput = theFunction(anInput); % function call returns an output
size(anOutput) % the function made an output with the same size as the input
function theOutput = theFunction(theInput) % function definition block
theOutput = cell(size(theInput));
%%% make a matrix
end
Btw to be clear in your actual example: link_vectors is an input, you call build_links, and it returns a copy of link_set.
回答 (1 件)
KSSV
2022 年 2 月 28 日
It seems you are straight away running the function. You need to provide the inputs to the function and then call the function.
link_vectors = rand(1,3) ; % define your input variables
% now call the function
link_set = build_links(link_vectors);
参考
カテゴリ
Help Center および File Exchange で Function Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!