Borrar filtros
Borrar filtros

Multiple Array Inputs for Self Written Function

1 visualización (últimos 30 días)
Guan Zhao
Guan Zhao el 3 de En. de 2013
Good day,
I would like to consult the community if there is a method to input multiple arrays into a self written function for processing.
For example suppose I have three matrices, x, y, and z, where x, y, and z, are matrices of different dimensions, and I would like to input them into one single function for processing in such manner:
[a, b, c] = functionF(x, y, z)
Attempting to input it this way would cause an error of having too many input arguments.
I would like to ask if there is a way for this to work.
Best Regards Guan Zhao
03/01/2013
  1 comentario
Azzi Abdelmalek
Azzi Abdelmalek el 3 de En. de 2013
I do not see where is the problem. [a, b, c] = functionF(x, y, z) is correct even the sizes of x,y and z are different

Iniciar sesión para comentar.

Respuesta aceptada

per isakson
per isakson el 3 de En. de 2013
Editada: per isakson el 3 de En. de 2013
Try to run
[ a, b, c ] = functionF( magic(3), magic(4), magic(5) );
where the following code is in a file with the name functionF.m
function [ a, b, c ] = functionF( x, y, z )
a=x;
b=y;
c=z;
end

Más respuestas (0)

Categorías

Más información sobre Language Fundamentals 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