how to zoomed plot in same figure

7 views (last 30 days)
Relly Syam
Relly Syam on 28 Jun 2021
Answered: Jakeb Chouinard on 3 Aug 2021
% clear;
clc;
format long e
tic
%bagian n=10
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) int(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=[1+c0;1+c1;1+c2;1+c3;1+c4;1+c5;1+c6;1+c7;1+c8;1+c9;1+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*exp(x)-1) ;
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
%bagian n=8
syms s0 s1 s2 s3 s4 s5 s6 s7 s8 t r0 r1 r2 r3 r4 r5 r6 r7 r8
s0=0/8; s1=1/8; s2=2/8; s3=3/8; s4=4/8; s5=5/8; s6=6/8; s7=7/8; s8=8/8; r0=0; r1=1; r2=2; r3=3; r4=4; r5=5; r6=6; r7=7; r8=8;
EvalAt = [s0, s1, s2, s3, s4, s5, s6, s7, s8];
ktemp = arrayfun(@(EA) euler([r0, r1, r2, r3, r4, r5, r6, r7, r8], EA).', EvalAt, 'uniform', 0);
ptemp=arrayfun(@(EA) int(euler([r0, r1, r2, r3, r4, r5, r6, r7, r8],t),t,0,EA).', EvalAt, 'uniform', 0);
E2 = horzcat(ktemp{:}).' ;
K2 = horzcat(ptemp{:}).' ;
Ek2=E2-K2 ;
Inv_Ek= inv(Ek2) ;
F2=[1+s0;1+s1;1+s2;1+s3;1+s4;1+s5;1+s6;1+s7;1+s8];
C2=Ek2\F2 ;
%solusi aproximasinya
Ua2=@(x)(C2(1)*euler(0,x)+C2(2)*euler(1,x)+C2(3)*euler(2,x)+C2(4)*euler(3,x)+C2(5)*euler(4,x)+C2(6)*euler(5,x)+C2(7)*euler(6,x)+C2(8)*euler(7,x)+C2(9)*euler(8,x)) ;
Ue=@(x)(2*exp(x)-1) ;
uaa2=zeros(11,1) ;
uee=zeros(11,1) ;
xx=zeros(11,1) ;
k=0;
for i=1:11
uaa2(i)=Ua2(k);
uee(i)=Ue(k);
xx(i)=k;
k=k+.1;
end
Uap2= uaa2;
Uex= uee;
y2=(abs(uaa2-uee));
[xx uee uaa2 y2];
uee
uaa2
y2
%bagian n=2
syms w0 w1 w2 t r0 r1 r2
w0=0/2; w1=1/2; w2=2/2; r0=0; r1=1; r2=2;
EvalAt = [w0, w1, w2];
ktemp = arrayfun(@(EA) euler([r0, r1, r2], EA).', EvalAt, 'uniform', 0);
ptemp=arrayfun(@(EA) int(euler([r0, r1, r2],t),t,0,EA).', EvalAt, 'uniform', 0);
E3 = horzcat(ktemp{:}).' ;
K3 = horzcat(ptemp{:}).' ;
Ek3=E3-K3 ;
Inv_Ek= inv(Ek3) ;
F3=[1+w0;1+w1;1+w2];
C3=Ek3\F3 ;
%solusi aproximasinya
Ua3=@(x)(C3(1)*euler(0,x)+C3(2)*euler(1,x)+C3(3)*euler(2,x)) ;
Ue=@(x)(2*exp(x)-1) ;
uaa3=zeros(11,1) ;
uee=zeros(11,1) ;
xx=zeros(11,1) ;
k=0;
for i=1:11
uaa3(i)=Ua3(k);
uee(i)=Ue(k);
xx(i)=k;
k=k+.1;
end
Uap3= uaa3;
Uex= uee;
y3=(abs(uaa3-uee));
[xx uee uaa3 y3];
uee
uaa3
y3
%gambar
plot(xx,uee,'k',xx,uaa,'o',xx,uaa2,'c*',xx,uaa3,'--')
grid on
legend({'eksak','aproksimasi N=10','aproksimasi N=8','aproksimasi N=2'},'Location','Northwest')
%plot(xx,y3)
%title('Error N=2')
%grid on
toc

Answers (1)

Jakeb Chouinard
Jakeb Chouinard on 3 Aug 2021
This quesiton has no description of the problem. That said, based on the title and the code shown, the only assumption I can make is that you're looking for something like xlim and ylim that would allow you to "zoom" in on a plot without creating a new figure. Hope this helps!

Categories

Find more on Time Series in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!