Difference of the two functions
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2021년 5월 29일
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')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!