# Creating empty cell array with function

16 visualizaciones (últimos 30 días)
Carly Hudson el 28 de Feb. de 2022
Comentada: AndresVar el 1 de Mzo. de 2022
% Use the 'cell' 'and 'size' commands to create an empty cell array the
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 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
Carly Hudson el 28 de Feb. de 2022
% Take a set of link vectors and augment each with a zero vector representing
% the base of the link
%
% Input:
%
% link_vectors: a 1xn cell array, each element of which is an mx1 vector
% from the base to end of a link, as seen in its *local* coordinate
% frame
%
% Output:
%
% link_set: a 1xn cell array, each element of which is a mx2 matrix whose
% first column is all zeros (representing the base of the link in its
% local frame) and whose second column is the link vector (end of the
% link) in its local frame
%%%%%%%%%%%%%%
% Use the 'cell' 'and 'size' commands to create an empty cell array the
%%%%%%%%%%%%%
% Loop over the vectors in link_vectors, constructing a matrix whose
% first column is all zeros and whose second column is the link vector,
% and saving this matrix in the corresponding column of link_set
end
this is the whole prompt. im just confused because link_vectors is something that already exists. so i dont know why i cant just call it in when i define link_set
AndresVar el 1 de Mzo. de 2022
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)
ans = 1×2
1 2
anOutput = theFunction(anInput); % function call returns an output
size(anOutput) % the function made an output with the same size as the input
ans = 1×2
1 2
function theOutput = theFunction(theInput) % function definition block
theOutput = cell(size(theInput));
%%% make a matrix
end

Iniciar sesión para comentar.

### Respuestas (1)

KSSV el 28 de Feb. de 2022
It seems you are straight away running the function. You need to provide the inputs to the function and then call the function.
% now call the function
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Carly Hudson el 28 de Feb. de 2022
% Take a set of link vectors and augment each with a zero vector representing
% the base of the link
%
% Input:
%
% link_vectors: a 1xn cell array, each element of which is an mx1 vector
% from the base to end of a link, as seen in its *local* coordinate
% frame
%
% Output:
%
% link_set: a 1xn cell array, each element of which is a mx2 matrix whose
% first column is all zeros (representing the base of the link in its
% local frame) and whose second column is the link vector (end of the
% link) in its local frame
%%%%%%%%%%%%%%
% Use the 'cell' 'and 'size' commands to create an empty cell array the
%%%%%%%%%%%%%
% Loop over the vectors in link_vectors, constructing a matrix whose
% first column is all zeros and whose second column is the link vector,
% and saving this matrix in the corresponding column of link_set
end
this is the whole prompt. im just confused because link_vectors is something that already exists. so i dont know why i cant just call it in when i define link_set

Iniciar sesión para comentar.

### Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by