Effacer les filtres
Effacer les filtres

Find five correct decimals of temp at x

2 vues (au cours des 30 derniers jours)
Katara So
Katara So le 10 Oct 2020
Commenté : Katara So le 10 Oct 2020
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!

Réponses (1)

Alan Stevens
Alan Stevens le 10 Oct 2020
How about using
T1 = interp1(x,T,1);
Use a finer mesh of x values if the result isn't satisfactory.
  1 commentaire
Katara So
Katara So le 10 Oct 2020
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?

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by