フィルターのクリア

Is there a way to plot the name of a point on a figure when it is plotted?

1 回表示 (過去 30 日間)
Brian
Brian 2013 年 5 月 6 日
Hello,
I need to change this code so that I can plot some of the node names next to the plotted nodes on the figure when it is plotted. (the plot would be of finite elements). Is there a way to do this? Thanks for your time
function PolyMshr_PlotMsh(Node,Element,NElem,Supp,Load) % In order to use the Matlab patch function to plot the entire mesh at once, we create an element connectivity matrix ElemMat that is padded with NaNs
clf; axis equal; axis off; hold on;
Element = Element(1:NElem)'; %Only plot the first block
MaxNVer = max(cellfun(@numel,Element)); %Max. num. of vertices in mesh %
PadWNaN = @(E) [E NaN(1,MaxNVer-numel(E))]; %Pad cells with NaN
ElemMat = cellfun(PadWNaN,Element,'UniformOutput',false);
ElemMat = vertcat(ElemMat{:}); %Create padded element matrix
patch('Faces',ElemMat,'Vertices',Node,'FaceColor','w'); pause(1e-6)
if exist('Supp','var')&&~isempty(Supp)&&~isempty(Load)%Plot BC if specified
plot(Node(Supp(:,1),1),Node(Supp(:,1),2),'b>','MarkerSize',8);
plot(Node(Load(:,1),1),Node(Load(:,1),2),'m^','MarkerSize',8); hold off;
end

回答 (1 件)

per isakson
per isakson 2013 年 5 月 6 日
The function
text( x, y, string )
will do that.
  5 件のコメント
Brian
Brian 2013 年 5 月 7 日
Sorry. I meant that there is an array (called fem.e ) which corresponds to these coordinates on the figure. Would I be able to print the numbers of the elements next to the element on the figure. thanks again
per isakson
per isakson 2013 年 5 月 7 日
編集済み: per isakson 2013 年 5 月 7 日
Yes,
text( x, y, sprintf( '#%i', the_number_of_the_element ) )
where x and y are retrieved from fem.e - I guess

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by