Problem :
I am very new to Matlab. I have written below code in my .M file:
function f = piecewise(w, C)
S=sqrt(diag(diag(C)));
s=diag(S);
f=sqrt(w'*C*w)/(w'*s);
I have already stored my file (piecewise.M) in my normal Matlab path, and so my assumption is that the Matlab will read my function when it will start and so my function must be available to be used.
But when I type below command
>> piecewise(w, C)
I start facing below error.
“Undefined function 'piecewise' for input arguments of type 'double'.”
Can you please help me in fixing above error?