Want to obtain plot between "W" and "lambda" for different values of "psi" but getting the following error.

1 次查看(过去 30 天)
syms x lambda
warning off
alpha = -0.1;
sigma = 0.1;
eps = -0.1;
e = 0.2;
M = 10;
a = 2;
figure
psi_list = [10, 20, 30, 40. 50];
for i = 1:numel(psi_list)
psi = psi_list(i);
hbar = @(x) a - a.*x + x;
A1 = eps + alpha^3 + (3 * sigma^2 * alpha);
B1 = @(x,lambda) (-3 * lambda * M) * ((hbar(x).^2) + (2 .* hbar(x) .* alpha) + (sigma^2) + (alpha^2));
a1 = @(x) tanh(M .* hbar(x));
b1 = @(x) 1 - ((tanh(M .* hbar(x))).^2);
c1 = (M * alpha) - ((M^3 * A1)/3);
d1 = @(lambda) 2 * (M^2) * (1 + lambda);
C1 = @(x) a1(x) + (b1(x) .* c1);
D1 = @(x,lambda) d1(lambda) .* ((hbar(x).^3) + (3 .* (hbar(x).^2) .* alpha) + (3 .* hbar(x) .* (alpha)^2) + (3 .* hbar(x) .* (sigma)^2) + eps + (3 * alpha * (sigma^2)) + (alpha^3));
f1 = @(x,lambda) B1(x) + (3 * lambda .* C1(x) .* hbar(x)) + (3 * lambda .* C1(x) .* alpha) + (D1(x,lambda) .* C1(x));
f2 = @(x,lambda) 12 * (M^2) * (1 + lambda) .* C1(x);
f3 = psi * (e^3);
f4 = @(lambda) (1 + lambda) *180 * ((1 - e)^2); % 180 is not given in paper
f5 = @(lambda) 1/(2 + lambda);
F = @(x,lambda) ((f5 .* f1(x))./f2(x)) + (f3/f4);
q1 = @(x,lambda) hbar(x) ./ (2 .* F(x));
Q1 = @(lambda) integral(q1,0,1);
q2 = @(x,lambda) 1./(F(x));
Q2 = @(lambda) integral(q2,0,1);
Q = Q1(lambda)/Q2(lambda);
p1 = @(x,lambda) (1./F(x)) .* ((0.5 .* hbar(x)) - Q);
P = @(x,lambda) integral(p1,0,x);
% W is obtained by integrating "P" with respect to x limit of x is 0 to
% 1 and W is still a function of lambda.
W =@(lambda) integral(P,0,1);
fplot(W(lambda), [0 1])
end
Not enough input arguments.

Error in solution (line 17)
B1 = @(x,lambda) (-3 * lambda * M) * ((hbar(x).^2) + (2 .* hbar(x) .* alpha) + (sigma^2) + (alpha^2));

Error in solution (line 27)
f1 = @(x,lambda) B1(x) + (3 * lambda .* C1(x) .* hbar(x)) + (3 * lambda .* C1(x) .* alpha) + (D1(x,lambda) .* C1(x));

Error in solution (line 33)
F = @(x,lambda) ((f5 .* f1(x))./f2(x)) + (f3/f4);

Error in solution (line 35)
q1 = @(x,lambda) hbar(x) ./ (2 .* F(x));

Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);

Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);

Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);

Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);

Error in solution (line 36)
Q1 = @(lambda) integral(q1,0,1);
legend(num2str(psi_list'))
ylim([0 1])
set(gca, 'ytick', 0:0.1:1);
set(gca, 'xtick', 0:0.2:1);
xlabel('x')
ylabel('W(lambda)')

采纳的回答

Ramishetti sai sreeja
  3 个评论
Star Strider
Star Strider 2022-7-8
It is throwing the error because you need to pass both ‘x’ and ‘lambda’ to those functions and you are only passing ‘x’ to them.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by