フィルターのクリア

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 Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by