'Error using - Matrix dimensions must agree.' Using anonymous functions
Mostrar comentarios más antiguos
I'm having some issues using anonymous functions, giving the error message 'Error using - Matrix dimensions must agree.' Code given below. R3 is a 3x1 vector, and all other variables not defined below are scalars.
f=1/(1+p^2+q^2)*[1-p^2+q^2 2*p*q -2*p]';
g=1/(1+p^2+q^2)*[2*p*q 1+p^2-q^2 2*q]';
X=@(F) a*((1-h^2*b)*cos(F)+h*k*b*sin(F)-k);
Y=@(F) a*((1-k^2*b)*sin(F)+h*k*b*cos(F)-h);
r=@(F) f*X(F)+g*Y(F);
dX=@(F) n*a^2/norm(r(F))*(h*k*b*cos(F)-(1-h^2*b*sin(F)));
dY=@(F) n*a^2/norm(r(F))*(-h*k*b*sin(F)+(1-k^2*b*cos(F)));
v=@(F) f*dX(F)+g*dY(F);
%Error is detected on this line
D=@(F) (r(F)-R3)*Cr*As*SF*Rs^2/(2*m*c*norm(r(F)-R3)^3);
da=@(F) 2*v(F)/(n^2*a);
symCja=@(F) 1/pi*dot(da(F),D(F))*cos(j*F);
Cj(1)=integral(symCja,-180,180);
I've tried calculating D using explicit values for F and it tells me that both r(F) and R3 are 3x1 vectors, so I don't see where the matrix dimensions issue comes from. I've also made sure that every other variable in that expression is a scalar, so I'm stumped- though my understanding of how anonymous functions actually work is very limited. Can anyone suggest where the issue might be coming from?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Numerical Integration and Differentiation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!