What's the accepted way to define a constant inside a function? Example:
____________________________________
function [sc, err] = symmcomp(abc)
% Function accepts [abc] complex components and delivers symmetrical
% components as a vector [x0, x1, x2] of complex values
persistent a = complex(-0.5, sqrt(3)/2); % Rotation vector
%
% Build conversion matrix_type (constant)
persistent A = [1, 1, 1;
1, a, a^2;
1, a^2, a]./3;
%
% Make abc a column vector
if (length(abc)>3)
sc = [];
err = "Too many components!";
elseif (length(abc)<3)
sc = [];
err = "Too few components!";
else
abc = reshape(abc,[3,1]);
sc = A*abc;
err = "";
endif
endfunction
________________________________________
Here a is a constant and A is a constant matrix. I used persistent in hopes
it would prevent them from being redefined every time the function is called.
In C++ I would use the "const" keyword.
Regards,
Allen