Effacer les filtres
Effacer les filtres

can anyone help me show the results?

1 vue (au cours des 30 derniers jours)
Relly Syam
Relly Syam le 27 Mai 2021
Commenté : Walter Roberson le 27 Mai 2021
% 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

Réponse acceptée

Walter Roberson
Walter Roberson le 27 Mai 2021
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{:}).'
E = 11×11
1 -0.5 0 0.25 0 -0.5 0 2.125 0 -15.5 0 1 -0.4 -0.09 0.236 0.0981 -0.47524 -0.295029 2.0208716 1.67213961 -14.741279044 -15.2462570049 1 -0.3 -0.16 0.198 0.1856 -0.40368 -0.560896 1.7187888 3.18043136 -12.539467008 -28.9999384576 1 -0.2 -0.21 0.142 0.2541 -0.29282 -0.771561 1.2485422 4.37721081 -9.110266562 -39.9147115101 1 -0.1 -0.24 0.074 0.2976 -0.15376 -0.906624 0.6563024 5.14546176 -4.789470976 -46.9222938624 1 0 -0.25 0 0.3125 0 -0.953125 0 5.41015625 0 -49.3369140625 1 0.1 -0.24 -0.074 0.2976 0.15376 -0.906624 -0.6563024 5.14546176 4.789470976 -46.9222938624 1 0.2 -0.21 -0.142 0.2541 0.29282 -0.771561 -1.2485422 4.37721081 9.110266562 -39.9147115101 1 0.3 -0.16 -0.198 0.1856 0.40368 -0.560896 -1.7187888 3.18043136 12.539467008 -28.9999384576 1 0.4 -0.09 -0.236 0.0981 0.47524 -0.295029 -2.0208716 1.67213961 14.741279044 -15.2462570049
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)]
F = 11×1
0 0.199666833293656 0.397338661590122 0.591040413322679 0.778836684617301 0.958851077208406 1.12928494679007 1.28843537447538 1.43471218179905 1.56665381925497
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
Uap = 11×1
7.105427357601e-15 0.245503548323686 0.60873596935765 1.14313645617895 1.92632442428365 3.07103790125495 4.7410208095578 7.1740972044101 10.7156840088336 15.8674641487411
Uex= uee
Uex = 11×1
0 0.22103418361513 0.488561103264068 0.809915284545602 1.19345975811302 1.64872127070013 2.18654256046861 2.81925379045867 3.56086548558795 4.42728560008251
y=(abs(uaa-uee));
[xx uee uaa y];
uee;
uaa;
y
y = 11×1
7.105427357601e-15 0.0244693647085567 0.120174866093582 0.333221171633345 0.732864666170633 1.42231663055483 2.55447824908919 4.35484341395143 7.1548185232457 11.4401785486585
Ermax=max(abs(uaa-uee))
Ermax =
17.921515417441
plot(xx,uaa,'o',xx,uee,'r')
grid on
plot(xx,y)
grid on
toc
Elapsed time is 53.250795 seconds.
  3 commentaires
Relly Syam
Relly Syam le 27 Mai 2021
I forgot the 'K' matrix part, can you help me show the results
Walter Roberson
Walter Roberson le 27 Mai 2021
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')

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by