필터 지우기
필터 지우기

Find five correct decimals of temp at x

조회 수: 2 (최근 30일)
Katara So
Katara So 2020년 10월 10일
댓글: Katara So 2020년 10월 10일
If I have a plot, how can I find the temperature at x=1 with five accurate decimals? It must be a way in which I have compared and can trust that the decimals are in fact accurate.
For example, say this is my code:
clear all, close all, clc
L=3.4;
N=100;
T0=300;
Tslut=410;
h=L/N;
x=linspace(0,L,N+1);
x=x.';
fk=@(x)2+x/7;
fQ=@(x)260*exp(-(x-L/2)^2);
A=zeros(N+1);
b=zeros(N+1,1);
A(1,1) = 1.0;
b(1) = T0;
for i=2:N
xp=x(i);
xhl=xp-h/2;
xhr=xp+h/2;
A(i,i-1) = -fk(xhl);
A(i,i) = (fk(xhl)+fk(xhr));
A(i,i+1) = -fk(xhr);
b(i) = fQ(xp)*h^2;
end
A(N+1,N+1) = 1.0;
b(N+1) = Tslut;
T=A\b;
plot(x,T)
All help is appreciated!

답변 (1개)

Alan Stevens
Alan Stevens 2020년 10월 10일
How about using
T1 = interp1(x,T,1);
Use a finer mesh of x values if the result isn't satisfactory.
  댓글 수: 1
Katara So
Katara So 2020년 10월 10일
I thought about using that however our professor said that we have to show what makes us trust the five decimals. I don't really know how interp1 works and therefore I don't know if the answer given is trustworthy. Would be a good enough way of checking the decimals?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by