Matlab contour labels for PDEs

  • MATLAB
  • Thread starter ephedyn
  • Start date
  • Tags
    Matlab Pdes
In summary, the person is asking if there is a way to label contours for PDEs on Matlab. They have tried using the pdeplot and pdecont functions, but these do not provide labels. They have also tried using the clabel function, but it does not work with their data. They are looking for a solution to transform their coordinates and PDE solution values into a specific form that is required for the clabel function to work. Other users have also asked for help with similar issues, but no solution has been found.
  • #1
ephedyn
170
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
  • #3
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.
 
  • #4
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
 
  • #5
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'...)
 
  • #6
It's ok. Thank u for ur time.
 
  • #7
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
 

1. How do I add contour labels to my PDE plot in Matlab?

To add contour labels to a PDE plot in Matlab, you can use the contourc function. This function returns the contour matrix, which contains the coordinates of the contour lines. You can then use the clabel function to add labels to the contour lines.

2. Can I customize the contour labels in Matlab for PDEs?

Yes, you can customize the contour labels in Matlab for PDEs. The clabel function allows you to specify the contour levels you want to label, the label format, and the label positions. You can also use the LabelSpacing property to adjust the spacing between labels.

3. How do I change the font size of the contour labels in Matlab?

To change the font size of the contour labels in Matlab, you can use the FontSize property of the clabel function. This property allows you to specify the font size in points.

4. Can I add units to my contour labels in Matlab for PDEs?

Yes, you can add units to your contour labels in Matlab for PDEs. You can use the clabel function to add a label format that includes the units. For example, you can use clabel(C,h,'LabelSpacing',200,'LabelFormat','%6.3f meters') to add the unit "meters" to your contour labels.

5. How can I adjust the position of the contour labels in Matlab?

You can adjust the position of the contour labels in Matlab by using the LabelSpacing property of the clabel function. This property allows you to specify the spacing between labels in points. You can also use the LabelRotation property to rotate the labels.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
121
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
952
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Topology and Analysis
Replies
1
Views
774
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top