Filter löschen
Filter löschen

Heat equation using Boundary condition

3 Ansichten (letzte 30 Tage)
MOHIT SWADIA
MOHIT SWADIA am 9 Okt. 2023
Beantwortet: Torsten am 9 Okt. 2023
function [b,c] = eql (x,t,u,dudx)
C=1; b=dudx; s=0;
end
function value = initial (x)
value=2*x / (1+x^2)
end
function [pl,ql, pr,qr]= ba(xl,ul,xr,ur,t)
pl=ul; ql=0; pr=ur-1; qr=0;
end
u=pdepe(0,@eql,@initial,@ba,x,t)
This statement is not inside any function.
(It follows the END that terminates the definition of the function "ba".)
x=linspace(0,1,20);
t=linespace(0,2,10);
surf(x,t,u)
title('Surface plot of solution')
xlabel('Distance X')
ylabel('time T')
zlabel('z axis')
grid on
I ma unable to understand the error. Please help me to understand and rectify the error...

Antworten (2)

Alan Stevens
Alan Stevens am 9 Okt. 2023
function statements of this form (i.e. functions eq1, initial and ba) need to go at the end of the script, not the start.

Torsten
Torsten am 9 Okt. 2023
x=linspace(0,1,20);
t=linspace(0,2,10);
u=pdepe(0,@eql,@initial,@ba,x,t);
surf(x,t,u)
title('Surface plot of solution')
xlabel('Distance X')
ylabel('time T')
zlabel('z axis')
grid on
function [c,f,s] = eql (x,t,u,dudx)
c=1; f=dudx; s=0;
end
function value = initial (x)
value=2*x / (1+x^2);
end
function [pl,ql, pr,qr]= ba(xl,ul,xr,ur,t)
pl=ul; ql=0; pr=ur-1; qr=0;
end

Kategorien

Mehr zu Thermal Analysis 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