can anyone help me show the results?
1 次查看(过去 30 天)
显示 更早的评论
% clear;
clc;
format long g
tic
syms c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 t r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10
c0=0; c1=0.1; c2=0.2; c3=0.3; c4=0.4; c5=0.5; c6=0.6; c7=0.7; c8=0.8; c9=0.9; c10=1; r0=0; r1=1; r2=2; r3=3; r4=4; r5=5; r6=6; r7=7; r8=8; r9=9; r10=10;
EvalAt = [c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10];
ktemp = arrayfun(@(EA) euler([r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10], EA).', EvalAt, 'uniform', 0);
ptemp=arrayfun(@(EA) 4*int(cos(EA-t)*euler([r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10],t),t,0,EA).', EvalAt, 'uniform', 0);
E = horzcat(ktemp{:}).'
K = horzcat(ptemp{:}).'
Ek=E-K ;
Inv_Ek= inv(Ek) ;
F=[2*sin(c0);2*sin(c1);2*sin(c2);2*sin(c3);2*sin(c4);2*sin(c5);2*sin(c6);2*sin(c7);2*sin(c8);2*sin(c9);2*sin(c10)]
C=Ek\F ;
%solusi aproximasinya
Ua=@(x)(C(1)*euler(0,x)+C(2)*euler(1,x)+C(3)*euler(2,x)+C(4)*euler(3,x)+C(5)*euler(4,x)+C(6)*euler(5,x)+C(7)*euler(6,x)+C(8)*euler(7,x)+C(9)*euler(8,x)+C(10)*euler(9,x)+C(11)*euler(10,x)) ;
Ue=@(x)(2*x*exp(x)) ;
uaa=zeros(11,1) ;
uee=zeros(11,1) ;
xx=zeros(11,1) ;
k=0;
for i=1:11
uaa(i)=Ua(k);
uee(i)=Ue(k);
xx(i)=k;
k=k+.1;
end
Uap= uaa
Uex= uee
y=(abs(uaa-uee));
[xx uee uaa y];
uee;
uaa;
y
Ermax=max(abs(uaa-uee))
plot(xx,uaa,'o',xx,uee,'r')
grid on
plot(xx,y)
grid on
toc
0 个评论
采纳的回答
Walter Roberson
2021-5-27
format long g
tic
syms c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 t r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10
c0=0; c1=0.1; c2=0.2; c3=0.3; c4=0.4; c5=0.5; c6=0.6; c7=0.7; c8=0.8; c9=0.9; c10=1; r0=0; r1=1; r2=2; r3=3; r4=4; r5=5; r6=6; r7=7; r8=8; r9=9; r10=10;
EvalAt = [c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10];
ktemp = arrayfun(@(EA) euler([r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10], EA).', EvalAt, 'uniform', 0);
ptemp=arrayfun(@(EA) 4*int(cos(EA-t)*euler([r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10],t),t,0,EA).', EvalAt, 'uniform', 0);
E = horzcat(ktemp{:}).'
K = horzcat(ptemp{:}).' ;
Ek=E-K ;
%Inv_Ek= inv(Ek) ;
F=[2*sin(c0);2*sin(c1);2*sin(c2);2*sin(c3);2*sin(c4);2*sin(c5);2*sin(c6);2*sin(c7);2*sin(c8);2*sin(c9);2*sin(c10)]
C = double(Ek)\F ;
%solusi aproximasinya
Ua=@(x)(C(1)*euler(0,x)+C(2)*euler(1,x)+C(3)*euler(2,x)+C(4)*euler(3,x)+C(5)*euler(4,x)+C(6)*euler(5,x)+C(7)*euler(6,x)+C(8)*euler(7,x)+C(9)*euler(8,x)+C(10)*euler(9,x)+C(11)*euler(10,x)) ;
Ue=@(x)(2*x*exp(x)) ;
uaa=zeros(11,1) ;
uee=zeros(11,1) ;
xx=zeros(11,1) ;
k=0;
for i=1:11
uaa(i)=Ua(k);
uee(i)=Ue(k);
xx(i)=k;
k=k+.1;
end
Uap= uaa
Uex= uee
y=(abs(uaa-uee));
[xx uee uaa y];
uee;
uaa;
y
Ermax=max(abs(uaa-uee))
plot(xx,uaa,'o',xx,uee,'r')
grid on
plot(xx,y)
grid on
toc
3 个评论
Walter Roberson
2021-5-27
I see that you edited your posting, but I do not find the difference .
If you want to display K, then after the end of the code I posted,
disp(K)
or
surf(double(K), 'edgecolor', 'none')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!