I’m trying to make a program in scilab (hopefully the same applies to matlab) to get the time where a stable vector is found, I mean, after making several times the product vector and matrix the result will became stable thus wont’ change.
I think the best way to do this is with a recursive function so I coded the following:
function [R]=vector_stable(v,m,i)
V=v*m;
if(V == v) then
R=i;
abort;
else
vector_stable(V,m,i+1);
end
endfunction
Let me explain that a little a bit, V is product of initial vector and the matrix, if the result is the same as the vector parameter then must return the time when this happened, if is not, it will call the same function with the result as the first parameter. However i’m getting the following error
-->R=vector_stable(V,M,0)
!--error 18
: Too many names.
Is my function correct? Can you help me please?
Your function doesn’t look right. This might be more like it: