Difference of the two functions
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
yogeshwari patel
le 29 Mai 2021
Commenté : yogeshwari patel
le 29 Mai 2021
I wrote the text for the two function as :
U=zeros(1,2,'sym');
A=zeros(1,2,'sym');
B=zeros(1,2,'sym');
C=zeros(1,2,'sym');
series(x,t)=sym(zeros(1,1));
U(1)=x^2/10
for k=1:5
A(1)=0;
C(1)=0;
for i=1:k
A(1)=simplify(A(1)+U(i)*U(k-i+1)) ;
end
for i=1:k
C(1)=simplify(C(1)+U(i)*diff(U(k-i+1),x,1));
end
U(k+1)=(simplify(2*C(1)+4*A(1)-3*U(k))))/k;
end
disp (U);
for k=1:6
series(x,t)=simplify(series(x,t)+U(k)*(power(t,k-1)));
end
series
C=zeros(10,10);
for x=1:10
for t=1:10
f=t/10;
C(x,t)=series(x,f);
end
end
u=zeros(10)
for x=1:10
for t=1:10
e=t/10;
u(x,t)=sin(x)+sin(e);
end
end
disp(u)
r=abs(u-C)
The code is showing the dimension error in the last line when is use the commmand surf(x,t,r)
0 commentaires
Réponse acceptée
Walter Roberson
le 29 Mai 2021
format long g
syms x t real
U=zeros(1,2,'sym');
A=zeros(1,2,'sym');
B=zeros(1,2,'sym');
C=zeros(1,2,'sym');
series(x,t)=sym(zeros(1,1));
U(1)=x^2/10
for k=1:5
A(1)=0;
C(1)=0;
for i=1:k
A(1)=simplify(A(1)+U(i)*U(k-i+1)) ;
end
for i=1:k
C(1)=simplify(C(1)+U(i)*diff(U(k-i+1),x,1));
end
U(k+1)=(simplify(2*C(1)+4*A(1)-3*U(k)))/k;
end
disp (U);
for k=1:6
series(x,t)=simplify(series(x,t)+U(k)*(power(t,k-1)));
end
series
C=zeros(10,10);
for x=1:10
for t=1:10
f=t/10;
C(x,t)=series(x,f);
end
end
u=zeros(10);
[X, T] = meshgrid(1:10, 1:10);
e = T/10;
u = sin(x) + sin(e);
r = abs(u-C)
surf(X, T, r)
xlabel('x');
ylabel('t');
zlabel('r')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!