function [no2xy, el2no, noExt] = ReadGrid(filename) % Function: % [no2xy, el2no, noExt] = ReadGrid(filename) % Arguments: % filename = the name of the file containing the grid % Returns: % no2xy = the coordinates of the nodes % el2no = the nodes of the triangles % noExt = the nodes on the outer boundary % Comments: % Reads the grid. % ------------------------------------------------------------- % | ADD YOUR READING OF THE MESH-FILES HERE. | % ---------------------------------------------------------- | % | | % \ / % \ / % \/ no2xy = readmatrix('xy.txt') ; el2no = readmatrix('nodes.txt'); noExt = readmatrix('boundary_nodes.txt'); close all figure hold on for i = 1:length(el2no) % Draw each triangle in elements list. x1 = no2xy(el2no(i,1), 1); y1 = no2xy(el2no(i,1), 2); x2 = no2xy(el2no(i,2), 1); y2 = no2xy(el2no(i,2), 2); x3 = no2xy(el2no(i,3), 1); y3 = no2xy(el2no(i,3), 2); plot([x1 x2 x3 x1], [y1 y2 y3 y1], 'b') end for i = 1:length(noExt) % Mark nodes on the boundary, given by list. x = no2xy(noExt(i), 1 ) y = no2xy(noExt(i), 2 ) plot(x,y,'r*') end % /\ % / \ % / \ % | | % ---------------------------------------------------------- | % | END OF CODE | % -------------------------------------------------------------
Error using readmatrix (line 158)
Unable to find or open 'xy.txt'. Check the path and filename or file permissions.
Error in ReadGrid (line 22)
no2xy = readmatrix('xy.txt') ;