Heat Equation Plot Problem

14 vues (au cours des 30 derniers jours)
Ljuboslav Boskic
Ljuboslav Boskic le 22 Sep 2017
Hi everyone. I'm new-ish to Matlab and I'm just trying to plot the heat equation, du/dt=d^2x/dt^2. I was trying to write a script based on the PDE toolbox and tried to follow examples but I don't want to use any boundary or initial conditions. I simply want this differential equation to be solved and plotted.
* * What my end goal is to essentially compare data that I have gathered to the equation. I gathered data for 0-24hrs (x-axis) and those values correspond to Temperature in Celcius (y-axis) which vary from 18-25 degrees Celcius. The data that I have resembles a cosine/sine curve. I just want to plot both on the same figure (which I have achieved with a basic cos(x) curve) and compare.
*I guess if I did need initial conditions x(0)=0, x(f)=24, but then I wouldn't know what to write for t (temperature) because I would just want it to vary based on the solution to the equation
Thank you!

Réponses (2)

David Ding
David Ding le 25 Sep 2017
Hi,
I am not quite understanding your workflow. First off, you do need initial conditions or boundary values to solve the differential equation, as the solution depends on those conditions. You are on the right track in that you need to input boundary values of temperature at time x = 0 and at time x = 24 (so this is a boundary-value problem). However, I do not understand what you mean by "I would just want it to vary based on the solution to the equation"? If you give boundary values for x = 0 and x = 24 (assume these values yield solutions), then you will obtain an unique solution.
If you are to obtain the unique solution based on your boundary conditions, please find the examples below to guide you:
Thanks,
David

Svetlana Pease
Svetlana Pease le 25 Sep 2017
Modifié(e) : Svetlana Pease le 26 Sep 2017
Hi Ljuboslav,
David is right: you need to specify boundary or initial conditions in order to solve this equation. Actually, du/dt = d^2x/dt^2, x(0) = 0, x(f) = 24 seems incorrect. I think you meant to solve the equation du/dt = d^2u/dx^2 with the boundary conditions u(0) = u0, (24) = u24, where u0 is temperature at t = 0 and u24 is the temperature at t = 24.
To see how existing data fits an equation, I would suggest using Curve Fitting Toolbox.
Regards,
Svetlana Pease
Technical writer, MathWorks documentation group
  2 commentaires
Ljuboslav Boskic
Ljuboslav Boskic le 25 Sep 2017
I'm sorry for the confusion. The way you said it, du/dt= d^2x/dt^2 is correct. I would like to look at u0 (temp) at t=0 and u24 (temp) at t=24. The problem I am having is actually writing a script for the equation itself. Like would I write my script like this,
syms u(x)
ode = diff(u,t,2) == diff(u,t);
cond1 = u(0)==0;
cond2 = u(24)==24;
conds = [cond1 cond2];
uSol(x) = dsolve(ode,conds);
So what I'm trying to say if I'm having a hard time starting my script and applying my boundary conditions to it. So I need to look at time 0 to 24 only but I need the temperature to vary freely. In other words, I need the temperature to freely vary from 0 degrees to 30 degrees freely.
I'm assuming to do this I'd use the linspace command,
t = linspace[0,30,110]
I'm hoping this clears up my confusion.
Thank you, Ljuboslav
Svetlana Pease
Svetlana Pease le 26 Sep 2017
Modifié(e) : Svetlana Pease le 26 Sep 2017
Sorry, I still don't understand which equation are you trying to solve. If it's a heat equation, can you please write it down, including what each variable and function stands for? In particular, what x, t, and u(x) are?
You can look up a heat equation here, for example:

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by