forループにいくつかのシンボリック変数があると、エラーが表示されます
??? The following error occurred converting from sym to double:
Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
問題は、シンボリック変数は積分変数であるため、計算の最後にシンボリック変数の値を差し込む必要があることです...どうすればこの問題を解決できますか???
function [product,Mi]=test(ii)
variables % this is just a numerical value for m, M and L
syms x y q B alp kk
product=zeros(3,1);
for i=1:3
for ni=1:9
n=new(ni); % All possible "n"s for each "ni" here new(ni) a function which gives different size matrix each time in the for loop
n_vector=zeros(1,3);
for jj=1:size(n,1)
n_vector(:)=n(jj,:);
p_vector=((2*pi/L)*(n_vector));
q_vector=((L/(2*pi))*[1,0,0]);
A=zeros(1,3);
if ii==1
Mi=sqrt(x.^2*M^2+(1-x).*m^2);
A=y.*p_vector;
elseif ii==2
Mi=sqrt(m^2-(x.*(1-x)).*q^2);
A=x.*q_vector;
elseif ii==3
Mi=sqrt((y.^2).*(M^2-(x.*(1-x)).*q^2)+(1-y).*m^2);
A=y.*(p_vector-q_vector*x);
elseif ii==4
Mi=sqrt((1-y).^2*M^2+y.^2*m^2-(x.*(1+x)).*y^2*q^2);
A=(1-y).*p_vector-(x.*y).*q_vector;
end
if i==1
product(i,1)=A(1,1)*n_vector(1,1)
else
product(i,1)=A(i,1)*n_vector(1,i)
end
end
end
end
end
ここに私の関数のほんの一部...「製品」が奇妙に見えることはわかっています。つまり、forループなしで式を書くことができますが、実際には私の関数では、そのような各製品にforループが必要です...