How to plot contour plots for data on the imported mesh nodes (not from PDE tool)
3 views (last 30 days)
Show older comments
Hi all,
I like the function trisurf, where I can plot nice figures imported from third party FEM software. But now I would like to make contour plots for the same results. There are some options for results obtained from PDE toolbox are not suitable for me because they work only with results from this particular toolbox.
0 Comments
Answers (1)
Ravi Kumar
on 19 Jul 2016
If having a PDE Toolbox results object solves your plotting problems, then you can create a PDE Toolbox results object using your mesh and solution data, without solving the problem in PDE Toolbox.
Note that this approach works only for problems defined in 3-D space.
Just create an appropriate PDEModel using createpde, transform mesh data into nodes and elements arrays and call geometryFromMesh. Then you use this PDEModel and your solution data, appropriately formatted, to call createPDEResults.
Ravi
2 Comments
Ravi Kumar
on 25 Jul 2016
Here is a workaround for 2-D geometries. This approach does not use PDE Toolbox features, so you don't need PDE Toolbox results object. Contouring function needs gridded data, this example shows how to convert scattered data into gridded data and use contour function on the processed data.
load trimesh2d
triplot(trife,xfe,yfe);
v = (xfe-150).^2 + (yfe-150).^2;
tr = triangulation(trife,xfe,yfe);
[xg, yg] = meshgrid(0:300);
[tg, bcg] = pointLocation(tr,xg(:),yg(:));
idx = isfinite(tg);
idxnan = isnan(tg);
tg = tg(idx);
bcg = bcg(idx,:);
triVals = v(tr(tg,:));
vg = dot(bcg',triVals')';
vall = NaN*xg(:);
vall(idx) = vg;
vg = reshape(vall, size(xg));
[~,hhc]=contour(xg, yg,vg,20);
hold on
fb = freeBoundary(tr)';
plot(xfe(fb), yfe(fb), '-k') ;
hold off
axis equal
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!