Search code examples
matlabpolygonmeshfinite-element-analysis

Matlab - FEM: Meshing polygon


I have problem with meshing this polygon:

enter image description here

I need fill this polygon with one of this finite element:

enter image description here

I don't how to type a code for this problem and then plot this polygon with mesh, all without using PDEtool.

Thank you.


Solution

  • I made sth like that:

    matX = [0,0.2,0;
            0.2,0.2,0;
            0.2,1,0.2;
            1,1,0.2;
            0,0.2,0;
            0.2,0.2,0;
            0.2,1,0.2]
    
    matY = [0,0,0.5;
            0,0.5,0.5;
            0,0,0.5;
            0,0.5,0.5;
            0.5,0.5,1;
            0.5,1,1;
            0.5,0.5,1]
    
    x = zeros(7,4);
    y = zeros(7,4);    
    
    for i=1:7    
        x(i,:) = [matX(i,1),matX(i,2),matX(i,3),matX(i,1)];
        y(i,:) = [matY(i,1),matY(i,2),matY(i,3),matY(i,1)];
        plot(x(i,:),y(i,:))
        hold on
    end
    

    Mesh:

    enter image description here

    Have anyone better and more sophisticated solution?