Error when using abs: Too many input arguments

4 Ansichten (letzte 30 Tage)
Sergio Manzetti
Sergio Manzetti am 22 Jun. 2021
Kommentiert: Dhruv G am 22 Jun. 2021
Hi, I am trying to plot the contour of the given function with the following:
syms r x y k z
[ph,r] = meshgrid((0:5:360)*pi/180,0:.5:10);
[X,Y] = pol2cart(ph,r);
Z = X+i*Y;
J = besselj(k,l.*r);
J2 = besselj(k,m.*r);
Y = bessely(k,l.*r);
Y2 = bessely(k,m.*r);
H = besselh(k,r);
F1 = symsum((J).*exp(1i*k*ph),k,-5,5);
F2 = symsum((J2+Y2).*exp(1i.*k.*ph),k,-5,5);
F3 = symsum(H.*exp(1i.*k.*ph),k,-5,5);
pwu = nan(size(F1), 'like', F1);
mask = 0 <= r & r < 0.5;
pwu(mask) = F1(mask);
mask = 0.5 <= r & r < 1;
pwu(mask) = F2(mask);
mask = r >= 1;
pwu(mask) = F3(mask);
U = subs(pwu, {l, m}, {1.5, 3});hold on
contour(X,Y,abs(double(U)),30)
axis equal
xlabel('r','FontSize',14);
ylabel('phi','FontSize',14);
But I get the error that there too many input arguments. If I remove "double" from the 4th last line, then it says input arguments must be numeric so to be converted to a double. So which way is correct here?
Thanks!

Antworten (1)

Dhruv G
Dhruv G am 22 Jun. 2021
If you type 'U' in the command window you would find that it is an array of symbolic equations (or expressions I'm not too sure). I think this is happening due to the symsum in your code. This is why it's not possible to cast U into a double and why you're getting the error.
  2 Kommentare
Sergio Manzetti
Sergio Manzetti am 22 Jun. 2021
Thanks for this. Does it mean I cannot plot the contour of this function?
Dhruv G
Dhruv G am 22 Jun. 2021
I think if you replace symsum with a function that does what you want numerically it should be possible

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by