In MATLAB, brackets([
and ]
) are used for matrices, whose elements have an identical type. Braces({
and }
) are used for cell arrays, whose elements can (and usually do) have different types.
However, the definition of a function in MATLAB uses brackets:
function [A, B, C] = func(x, y, z)
A = length(x) + 1i * length(y);
B = zeros(size(y));
C = int2str(z);
end
Here, A is a complex number, B is a matrix, and C is a string.
Why does this so? Why not braces for this like:
function {A, B, C} = func(x, y, z)
A = length(x) + 1i * length(y);
B = zeros(size(y));
C = int2str(z);
end
which causes a compile error (I mean, a syntax error).