Assignment has more non-singleton rhs dimensions than non-singleton subscripts.
7 次查看(过去 30 天)
显示 更早的评论
How can I solve this problem?
the code is long due to the use of multible user defined function and I will post every thing necessary if needed!
Below is the main code.
function [temp2]=test2(n1,n2)
clc
n1=2; n2=2; %just for the example!
syms x t
G=legendreSpan('gxt',n1,n2); %legendrespan is a (n+1)x(n+1) matrix of scalars (known)
P=Plegendre(n2); %since n1=n2 it does not matter and Plegendre is a (n+1)x(n+1) matrix of scalars (known)
D=Dlegendre(n1); %Dlegendre is a (n+1)x(n+1) matrix of scalars (known)
n1=n1+1; n2=n2+1;
A = sym('a', [n1 n2]);
temp2=sym(zeros(n1,n2));
E=A*D-A-G-A*P;
fun1=@(x,t) (qx(x,n1))'*E*(qx(t,n2)); %qx is a 1x(n+1) column vector
for i=0:n1-1
for j=0:n2-1
fun4=@(x,t)legendre(i,x).*fun1(x,t).*legendre(j,t); %legendre is a 1x1 vector
temp2(i,j)= integral2(fun4,0,1,0,1);
end
end
end
The command window shows the follwing when I run the code
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in sym/privsubsasgn (line 1031)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in sym/subsasgn (line 868)
C = privsubsasgn(L,R,inds{:});
Error in qx (line 5)
Q(i+1,1)=legendre(i,x);
Error in test2>@(x,t)(qx(x,n1))'*E*(qx(t,n2)) (line 13)
fun1=@(x,t) (qx(x,n1))'*E*(qx(t,n2));
Error in test2>@(x,t)legendre(i,x).*fun1(x,t).*legendre(j,t) (line 17)
fun4=@(x,t)legendre(i,x).*fun1(x,t).*legendre(j,t);
Error in integral2Calc>integral2t/tensor (line 228)
Z = FUN(X,Y); NFE = NFE + 1;
Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in integral2Calc (line 9)
[q,errbnd] = integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral2 (line 106)
Q = integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);
Error in test2 (line 18)
temp2(i,j)= integral2(fun4,0,1,0,1);
NOTE: every function runs perfectly without problems and the main code (test2) included until the code integral2(fun4,0,1,0,1); is start to run.
The functions that I defined and used in this code are legendrespan(f,n1,n2), Plegendre(n), Dlegendre(n), legendre and qx(x,n) and I can edit the question and post these functions if needed ,I just did not want the question to be long.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!