There is an error in drawing the graph!

1 ビュー (過去 30 日間)
Shikhnazar Ismailov
Shikhnazar Ismailov 2022 年 2 月 10 日
n=41; h=1/(n-1); nt=360; tau=0.001;
for i=1:n
x(i)=(i-1)*h;
y(i)=(i-1)*h;
end
for j=1:n
for i=1:n
p0(i,j)=1;
end
end
for jt=1:nt
t(jt)=jt*tau;
for j=1:n % Anlitik yechimni hisoblash
for i=1:n
pt(i,j)=exp(-2*x(i)*y(j)*t(jt));
end
end
end
tic
for jt=1:nt/2 % Vaqt bo`yicha tsikl}
[po,pp]=fxy(n,tau,h,p0,x,y,t,jt);
[po,pp]=fyx(n,tau,h,p0,x,y,t,jt);
end % jt
toc
for j=1:n
px(j)=pp(21,j);
pxt(j)=pt(21,j);
end
x=0:h:1;
y=0:h:1;
figure ('Position',[600 160 700 600]); %Natijalarni figuraga chiqarish oynasi: 750-eni, 650-boyi, 700-chapdan masofa, 75-yuqoridan masofa
subplot(3,2,1);
meshc(x,y,pt) %Uch o'lchovli 3D grafika
title('АНИК ЕЧИМ 3D ГРАФИГИ')
subplot(3,2,2);
meshc(x,y,pp) %Uch o'lchovli 3D grafika
title('CОНЛИ ЕЧИМ 3D ГРАФИГИ')
subplot(3,2,3);
contour(x,y,pt,'ShowText','on','LineWidth',2); %kontur chizish
title('АНИК ЕЧИМ КОНТУР ГРАФИГИ')
subplot(3,2,4);
contour(x,y,pp,'ShowText','on','LineWidth',2); %kontur chizish
title('CОНЛИ ЕЧИМ КОНТУР ГРАФИГИ')
subplot(3,2,5);
plot(x,px,x,pxt); %Ikki o'lchovli grafika
title('КЕСИМДА АНИК ВА CОНЛИ ЕЧИМ ЎЗГАРИШИ X БЎЙИЧА')
function [p0,p] = fxy(n,tau,h,p0,x,y,t,jt)
% k+0.5 vaqt qatlamida hisoblash
for j=2:n-1 % Tenglamalar koeffitsientini hisoblash
for i=2:n-1
%chekli ayirma tenglama koeffitsentlarini hisoblash
a(i)=1;
c(i)=1;
b(i)=2+2*h*h/tau;
ff=h*h*(-2*(2*t(jt)*t(jt)*(x(i)*x(i)+y(j)*y(j))+x(i)*y(j))*exp(-2*x(i)*y(j)*t(jt)));
d(i)=2*h*h/tau*p0(i,j)+(p0(i,j-1)-2*p0(i,j)+p0(i,j+1))+ff;
end
%Pragonka koeffitsentlarini hisoblash
aa1(1)=0; bb1(1)=1;
for i=2:n-1
aa1(i)=c(i)/(b(i)-aa1(i-1)*a(i));
bb1(i)=(d(i)+bb1(i-1)*a(i))/(b(i)-aa1(i-1)*a(i));
end
% bosim funktsiyasini hisoblash
p(n,j)=exp(-2*y(j)*t(jt));
for i=n-1:-1:1
p(i,j)=aa1(i)*p(i+1,j)+bb1(i);
end
end %j
for i=1:n % Chegaraviy qiymatlarni hisoblash
p(i,n)=(4.0*p(i,n-1)-p(i,n-2))/3;
p(i,1)=(4.0*p(i,2)-p(i,3))/3;
end
for j=1:n % k+1 qatlam uchun boshlangich qiymatni hisoblash
for i=1:n
p0(i,j)=p(i,j);
end
end
% k+1 vaqt qatlamida hisoblash
for i=2:n-1 % Tenglamalar koeffitsientini hisoblash
for j=2:n-1
%chekli ayirma tenglama koeffitsentlarini hisoblash
a(j)=1;
c(j)=1;
b(j)=2+2*h*h/tau;
ff=h*h*(-2*(2*t(jt)*t(jt)*(x(i)*x(i)+y(j)*y(j))+x(i)*y(j))*exp(-2*x(i)*y(j)*t(jt)));
d(j)=2*h*h/tau*p0(i,j)+(p0(i-1,j)-2*p0(i,j)+p0(i+1,j))+ff;
end
%Pragonka koeffitsentlarini hisoblash
aa1(1)=0; bb1(1)=1;
for j=2:n-1
aa1(j)=c(j)/(b(j)-aa1(j-1)*a(j));
bb1(j)=(d(j)+bb1(j-1)*a(j))/(b(j)-aa1(j-1)*a(j));
end
% bosim funktsiyasini hisoblash
p(i,n)=exp(-2*x(i)*t(jt));
for j=n-1:-1:1
p(i,j)=aa1(j)*p(i,j+1)+bb1(j);
end
end %i
for j=1:n % Chegaraviy qiymatlarni hisoblash
p(n,j)=(4.0*p(n-1,j)-p(n-2,j))/3;
p(1,j)=(4.0*p(2,j)-p(3,j))/3;
end
for i=1:n % keyingi qatlam uchun boshlangich qiymatni hisoblash
for j=1:n
p0(i,j)=p(i,j);
end
end
end
function [p0,p] = fyx(n,tau,h,p0,x,y,t,jt)
% k+1 vaqt qatlamida hisoblash
for i=2:n-1 % Tenglamalar koeffitsientini hisoblash
for j=2:n-1
%chekli ayirma tenglama koeffitsentlarini hisoblash
a(j)=1;
c(j)=1;
b(j)=2+2*h*h/tau;
ff=h*h*(-2*(2*t(jt)*t(jt)*(x(i)*x(i)+y(j)*y(j))+x(i)*y(j))*exp(-2*x(i)*y(j)*t(jt)));
d(j)=2*h*h/tau*p0(i,j)+(p0(i-1,j)-2*p0(i,j)+p0(i+1,j))+ff;
end
%Pragonka koeffitsentlarini hisoblash
aa1(1)=0; bb1(1)=1;
for j=2:n-1
aa1(j)=c(j)/(b(j)-aa1(j-1)*a(j));
bb1(j)=(d(j)+bb1(j-1)*a(j))/(b(j)-aa1(j-1)*a(j));
end
% bosim funktsiyasini hisoblash
p(i,n)=exp(-2*x(i)*t(jt));
for j=n-1:-1:1
p(i,j)=aa1(j)*p(i,j+1)+bb1(j);
end
end %i
for j=1:n % Chegaraviy qiymatlarni hisoblash
p(n,j)=(4.0*p(n-1,j)-p(n-2,j))/3;
p(1,j)=(4.0*p(2,j)-p(3,j))/3;
end
for i=1:n % keyingi qatlam uchun boshlangich qiymatni hisoblash
for j=1:n
p0(i,j)=p(i,j);
end
end
% k+0.5 vaqt qatlamida hisoblash
for j=2:n-1 % Tenglamalar koeffitsientini hisoblash
for i=2:n-1
%chekli ayirma tenglama koeffitsentlarini hisoblash
a(i)=1;
c(i)=1;
b(i)=2+2*h*h/tau;
ff=h*h*(-2*(2*t(jt)*t(jt)*(x(i)*x(i)+y(j)*y(j))+x(i)*y(j))*exp(-2*x(i)*y(j)*t(jt)));
d(i)=2*h*h/tau*p0(i,j)+(p0(i,j-1)-2*p0(i,j)+p0(i,j+1))+ff;
end
%Pragonka koeffitsentlarini hisoblash
aa1(1)=0; bb1(1)=1;
for i=2:n-1
aa1(i)=c(i)/(b(i)-aa1(i-1)*a(i));
bb1(i)=(d(i)+bb1(i-1)*a(i))/(b(i)-aa1(i-1)*a(i));
end
% bosim funktsiyasini hisoblash
p(n,j)=exp(-2*y(j)*t(jt));
for i=n-1:-1:1
p(i,j)=aa1(i)*p(i+1,j)+bb1(i);
end
end %j
for i=1:n % Chegaraviy qiymatlarni hisoblash
p(i,n)=(4.0*p(i,n-1)-p(i,n-2))/3;
p(i,1)=(4.0*p(i,2)-p(i,3))/3;
end
for j=1:n % k+1 qatlam uchun boshlangich qiymatni hisoblash
for i=1:n
p0(i,j)=p(i,j);
end
end
end
The graph looks like this.
The graphic should actually be like that!

回答 (1 件)

Benjamin Thompson
Benjamin Thompson 2022 年 2 月 10 日
Here you are drawing two lines:
subplot(3,2,5);
plot(x,px,x,pxt); %Ikki o'lchovli grafika
title('КЕСИМДА АНИК ВА CОНЛИ ЕЧИМ ЎЗГАРИШИ X БЎЙИЧА')
If you only intend to draw one line, remove the second dataset:
plot(x, px);
  2 件のコメント
Shikhnazar Ismailov
Shikhnazar Ismailov 2022 年 2 月 13 日
The second function takes the values of p and p0 derived from the first function. The first function takes the values of p and p0 derived from the second function. Only in the beginning does the first function work with the above values of p and p0, otherwise it must calculate the mutual exchange. How can I do this?

サインインしてコメントする。

カテゴリ

Find more on 2-D and 3-D Plots in Help Center and File Exchange

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by