How to Label Contours for PDEs in Matlab?

  • Context: MATLAB 
  • Thread starter Thread starter ephedyn
  • Start date Start date
  • Tags Tags
    Matlab Pdes
Click For Summary

Discussion Overview

The discussion revolves around labeling contours for partial differential equations (PDEs) in Matlab. Participants explore various functions and methods to achieve labeled contour plots, addressing issues related to data formatting and function compatibility.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about labeling contours generated by functions like pdeplot and pdecont, expressing frustration over the lack of labels.
  • Another suggests using contour and clabel functions, but the original poster indicates that this approach does not work due to the requirement for X and Y to be at least 2x2 matrices.
  • A participant confirms they have the same issue and seeks further assistance, indicating the importance of finding a solution.
  • One participant reports having to resort to using a color map instead of contour labels, expressing dissatisfaction with this workaround.
  • Another participant shares a separate issue regarding plotting data from a CSV file, mentioning that their code runs without errors but does not produce a figure, and questions the proper way to format the data for contour plotting.

Areas of Agreement / Disagreement

Participants generally agree on the challenges of labeling contours in Matlab, with multiple competing views on potential solutions. The discussion remains unresolved as no consensus on a working method has been reached.

Contextual Notes

Participants express uncertainty regarding the formatting of data and the requirements of the contour functions, indicating that the solutions may depend on specific data structures and function parameters.

ephedyn
Messages
169
Reaction score
1
Is there a way that I can label contours for PDEs on Matlab? They have a few functions for drawing contours, e.g.

pdeplot(p,e,t,'xydata',u,'mesh','off','contour','on',' ...)

pdecont(p,t,u)

but they're unlabelled (what's the use!) I'm sure there's a way to label my contours if I could plot them in the first place, but searches yield none. I understand that there's a function

clabel(X,Y,Z)

but I can't think of how I can use it with given my data:

p(1,:) is the matrix containing the x-coordinates of u(:,1)
p(2,:) is the matrix containing the y-coordinates of u(:,1)
u(:,1) gives the solutions.

e.g. u(1) gives the solution at (p(1,1), p(2,2))

I tried the obvious,

clabel(p(1,:),p(2,:),u(:,1))

which doesn't work as far as it goes because I realized X and Y refers to a grid rather than the coordinates of certain elements of Z. Similarly, Z are the values at the points in the grid, rather at only certain, irregularly spaced coordinates.

Any help is appreciated, thanks in advance!
 
Physics news on Phys.org
Yep, I've tried that. It doesn't work. :frown: I need to find a way to transform my x, y coordinates and PDE solution values into a strange form (X and Y must be at least 2x2 matrices).

Thanks nonetheless.
 
Hi..I have the same problem ! I can't label the contours which come from the pdeplot(...) or pdecont(...).
Any solution ?

ephedyn have u find anything ? Please answer me..its important. thanks
 
Hi, I'm sorry to disappoint you but I couldn't find a fix to this. I had to stick to a color map rather than contour labels, which is annoyingly inadequate.

pdeplot(...colormap, 'jet'...)
 
It's ok. Thank u for ur time.
 
Hey Guys

I would be grateful if you could have some time to look into my question, I am trying to do density plot (contour or surface or map)from a data file which has 3 columns...the code below does not shows any errors, but also does not give any figure, I think may be the way I had added the extension manually(.csv...comma separated variables)...is there anyway to export my data in such extension file...or if you have another way to plot data file by contour plot...:cry::cry:


Code:
data = csvread('my_file.csv');
x=data(:,1);
y=data(:,2);
z=data(:,3);
a=size(data);
b=a(:,1);
xlin=linspace(min(x),max(x),b);
ylin=linspace(min(y),max(y),b);
[X,Y]=meshgrid(xlin,ylin);
Z=griddata(x,y,z,X,Y);
mesh(X,Y,Z)
colorbar
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
2
Views
3K