MATLAB Answers

Can someone please assist me in plotting a 3-D surface?

2 views (last 30 days)
I want to plot a 3D graph of the series when alpha=0.25 and and k=1,2,...10.
This is my code but im getting an error :
alpha=0.25;
[x,t] = meshgrid(-4:.1:4, 0.1:.2:0.4);
k=[1:10];
A=exp(x);
B=(t.^(k.*alpha))./factorial(k).*alpha. ^k;
Invalid use of operator.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
C=sum(B);
D=A.*C;
mesh(t,x,D)
xlabel('t')
ylabel('x')
zlebel('u_10')

Accepted Answer

Omorodion Solomon
Omorodion Solomon on 21 Aug 2021

The approximate and exact solution are not corresponding. Please assist further. Here is my code:

alpha=0.25; r=5; t=0.002; x=[-5:0.2:5]; k = reshape(0:100, 1, 1, []); A=exp(x); B = (t.^(k.*alpha))./factorial(k).*alpha.^k; C = sum(B,3); Numerical=A.*C; Exact=A.*exp((r-4).*(t.^alpha)./(alpha)); Z1=Numerical; Z2=Exact; hZ1 = plot(x,Z1,'-r'); hold on hZ2 = plot(x,Z2,'-g'); hold off grid on xlabel('x') ylabel('u') legend([hZ1(1),hZ2(1)], 'CFRDTM','EXACT', 'Location','NE')

More Answers (1)

Walter Roberson
Walter Roberson on 19 Aug 2021
alpha=0.25;
[x,t] = meshgrid(-4:.1:4, 0.1:.2:0.4);
k = reshape(1:10, 1, 1, []);
A=exp(x);
B = (t.^(k.*alpha))./factorial(k).*alpha.^k;
C = sum(B,3);
D=A.*C;
mesh(t,x,D)
xlabel('t')
ylabel('x')
zlabel('u_10')
  3 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by