What is [] to the left of "=" means?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
[processed_I] = preA(handles, connected_I, 0);
Hi, is that the [] to the left of "=" means matrix? For example, if the function return a matrix of 3X3, so the left [] will get the matrix of 3X3 too? Thanks
0 comentarios
Respuestas (1)
Daniel Shub
el 9 de Mayo de 2012
In this case the [] does not mean anything
EDIT
[processed_I] = preA(handles, connected_I, 0);
and
processed_I = preA(handles, connected_I, 0);
mean the same thing. However
[processed_I processed_J] = preA(handles, connected_I, 0);
and
[processed_I, processed_J] = preA(handles, connected_I, 0);
are the same while
processed_I processed_J = preA(handles, connected_I, 0);
is invalid and
processed_I, processed_J = preA(handles, connected_I, 0);
mean something totally different. On the LHS of an assignment, the [] are used to denote that multiple outputs are expected such that the first output of a function is placed into processed_I and the second is placed into processed_J.
3 comentarios
Jan
el 9 de Mayo de 2012
It is trivial to check the validity of the code by your own - simply try it in Matlab.
"processed_I" will be the first output, "processed_J" the second one. The order of outputs is defined in the function header. A function defined by:
function [a, b] = fcn(c, d)
receives e.g. c as first input and replies b as second output.
These basics are explained exhaustively in the Getting Started chapters. It is recommended for all users to read them.
Ver también
Categorías
Más información sobre Multidimensional Arrays 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!