What is [] to the left of "=" means?
Ältere Kommentare anzeigen
[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
Antworten (1)
Daniel Shub
am 9 Mai 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 Kommentare
Superb
am 9 Mai 2012
Superb
am 9 Mai 2012
Jan
am 9 Mai 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.
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!