How do I used data exported from the PDE toolbox in order to create specific XY plots?

2 visualizzazioni (ultimi 30 giorni)
Using the partial differential equation toolbox, I have solved a few heat transfer problems. I understand how to export the data from the mesh and the solution, but am unable to use it to create a proper script. I am attempting to create two specific XY plots with the data from the toolbox, but am unsure how to use the appropriate functions with the mesh data that is exported.
The first thing I am attempting to create is a script a graph of the solution value along an arbitrary line drawn over the solution showed in the PDE toolbox. In other words, with the mesh data I can export I need to specify a certain straight line along the solution given in the toolbox, then plot the resulting temperature versus that line in an XY plot. I need to create a script in which I specify that line and then graph the solution at points along it.
The second plot I am attempting to create is an XY plot that shows the solution value (temperature) at a given point against the time that the heat is being applied in my problem. I need a script that will allow me to use the mesh data to specify a point, then graph the temperature at that point against time.

Risposta accettata

Alan Weiss
Alan Weiss il 11 Lug 2017
Depending on your toolbox version, there are differing ways to plot things. If you have a relatively recent version, then use Plot 2-D Solutions and their Gradients, especially the latter part of the example, which shows how to interpolate the results to a straight line segment.
If you are using an old toolbox version where you have to use a [p e t] representation of the mesh, then you can use pdeInterpolant to create an interpolant, and use evaluate to create the interpolated values. The evaluate function reference page has several examples.
Alan Weiss
MATLAB mathematical toolbox documentation
  6 Commenti
Alex Johnson
Alex Johnson il 13 Lug 2017
That worked well thank you. But lets say that I wanted to plot along a line that is not horizontal. It would be something like this.
x=linspace(x1,x2); y=linspace(y1,y2); uout=evaluate(F,x,y);
But then I get stuck when plotting. I cannot plot against the x or y axis because my arbitrary line is diagonal, so the end of my plot should end at whatever distance the line is. I would think that to do this you would plot uout against the line because you cannot make a 2d plot with x, y, and uout. However, I am unable to create a line that I could plot this along that is in the correct format with agreeing matrices. I have also gotten errors which say line cannot be child of line when I tried to manually enter the line to plot against. Thanks!
Alan Weiss
Alan Weiss il 18 Lug 2017
There are many ways to plot in MATLAB. Again, I suggest that you look at the latter part of this example and see how the plotting on a diagonal was done (look for "Plot the interpolated solution along the line." and the immediately following figures).
Alternatively, if you have a line parameterized by t, plot along the parametrization, such as
t = linspace(0,1);
x = -1 + 0.5*t;
y = 2 - 0.1*t;
uout = evaluate(F,x,y); % Assumes F exists
plot(t,uout)
Alan Weiss
MATLAB mathematical toolbox documentation

Accedi per commentare.

Più risposte (1)

Ravi Kumar
Ravi Kumar il 10 Lug 2017
If you are using MATLAB R2017a, refer to the examples in this page, particularly the last one.

Community Treasure Hunt

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

Start Hunting!

Translated by