The function besselj(nu,x) is in fact two variable function
as
. you put v(i) and z(i) simultaneously with same index in argument of it. means M(i) is
which make it one dimensional array. you should consider some v as you already created and a linespace for spatial variable.



v = unique(randi(12, [1,4])-1);
z = linspace(0,10*(1+rand(1)),2e2).';
for i = 1:numel(v)
M(i,:)=besselj(v(i),z);
end
plot(z,M,'LineWidth',2);grid on;
legend(['J_{' num2str(v(1)) '}'],['J_{' num2str(v(2)) '}'],['J_{' num2str(v(3)) '}'],['J_{' num2str(v(4)) '}'])
if size of v be less than 4 the line legends leads to an array.