How do I use the besselj function?

3 次查看(过去 30 天)
I've been given a row vector v and column vector z:
v = unique(randi(12, [1,4])-1);
z = linspace(0,10*(1+rand(1)),2e2).';
I'm supposed to produce an array M=Jv(z), where the columns of M(z) correspond to each value of v.
This is what I've made so far:
for i = [1:length(v)]
M(i)=besselj(v(i),z(i))
end
I had thought I made a correct array of M, with it being a 1x4 function, like v. However this doesn't allow me to make M a function of z, and I have a feeling I've completely misunderstood the documentation of the besselj function altogether.

采纳的回答

Abolfazl Chaman Motlagh
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by