Filter löschen
Filter löschen

Find five correct decimals of temp at x

2 Ansichten (letzte 30 Tage)
Katara So
Katara So am 10 Okt. 2020
Kommentiert: Katara So am 10 Okt. 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!

Antworten (1)

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by