How can i graph ponits with coord and value assigned, as colour graph

1 次查看(过去 30 天)
I am writing a Finite Element Method routine. Y have the coordinates of difrents points (x1,y1,x2,y2,x3,y3,.....) each point with a stress value asign. The idea is to graph those points with colors according to their values. It should look something like this:
thanks for any help!

回答(3 个)

Hugo
Hugo 2013-6-14
Have you taken a look at the command patch ? For example
patch('Vertices',V,'Faces',F,'FaceVertexCData',D,'FaceColor','interp','EdgeColor',somecolour,'FaceLighting','phong');
Suppose that you have N points
V are the spatial positions of the points: What you call coordinates.
F is a matrix of M rows and 3 columns. Each element in each row is a point (row in V). The three points define a triangle like the one in your figure example.
D is the stress value at each point.
The other options only change the colour presentation. "somecolour" should be replaced by a colour.
You can use in addition
colormap somecolormap;
colorbar
for changing the colormap (between hot, gray, or your own definition) and to add the colorbar.
Hope this helps. Best regards

German
German 2013-6-14
First of all, thanks! It worked pretty well, but there were some details: -The points i have, are not the nodes of the elements, but they are the gaus points (points inside de element) for each element. So i had to make a small routine to connect all the points with there "neighbor" points on every element. But there was a lack of connectivity between the point of differents elements. A image is worth more than thousen words..
So is there any way to not have to give the conectivity between points?
Any way, i works pretty good for the objective i had in mind, im asking just in case of... to make an even better job! Thanks for all man! you save me a lot of time!

Hugo
Hugo 2013-6-14
The result of patch depends on the patches you define, so at least using patch, there is no other way.
What you can certainly do is to avoid patch and use surf if you only want to plot surfaces in 2D. But surf requires a 2D uniform grid. So you will need to define a 2D grid and then find the values in each node of the grid by combining the values at different locations using, for example, Gaussian filters (i.e. a Gaussian function in 2D). Are you familiar with that?
Best regards

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by