{"id":1261,"date":"2020-07-14T06:14:59","date_gmt":"2020-07-14T06:14:59","guid":{"rendered":"https:\/\/people.utm.my\/arazin\/?p=1261"},"modified":"2020-07-14T11:46:28","modified_gmt":"2020-07-14T11:46:28","slug":"q4fem_code","status":"publish","type":"post","link":"https:\/\/people.utm.my\/arazin\/2020\/07\/14\/q4fem_code\/","title":{"rendered":"Create Q4 Elements for 2d Rectangular Domain (Octave\/MATLAB)"},"content":{"rendered":"<pre>function [node_xy,elem_node] = ElemQ4(L,H,m,n,varargin)\r\n\r\n% ====================================================%\r\n% function to create Q4 elements (2D)                 %\r\n% INPUT:                                              %\r\n% &gt; length (L) and height (H),                        %\r\n% &gt; division over x (m) and division over y (n)       %\r\n% &gt; option for plotting (varargin)                    %\r\n% OUTPUT:                                             %\r\n% &gt; coordinate of nodes [node_xy]                     %\r\n% &gt; element connectivity [elem_node]                  %\r\n% ====================================================%\r\n\r\n% Nodes coordinates [x y]\r\n[x,y] = meshgrid(0:L\/m:L,0:H\/n:H);\r\nnode_xy = [x(:) y(:)];\r\nnode_xy = sortrows(node_xy,2);\r\n\r\n% Connectivity matrix [node1 node2 node3 node4]\r\nelem_node = [];\r\nfor i = 1:n\r\n   for j = 1:m\r\n      elem_i = [[j j+1] [j+1 j]+(m+1)] + (m+1)*(i-1);\r\n      elem_node = cat(1,elem_node,elem_i);\r\n   end\r\nend\r\n\r\n\r\n%===================================\r\n% Plot (optional)\r\n%===================================\r\nif nargin &gt; 4\r\n   figure\r\n   plot(node_xy(:,1),node_xy(:,2),'ro')\r\n   hold on \r\n   for j = 1:size(elem_node,1)\r\n      for k = 1:size(elem_node,2)-1\r\n         pause(0.2)\r\n         plot(node_xy(elem_node(j,k:k+1),1),...\r\n         node_xy(elem_node(j,k:k+1),2),'b:','linewidth',3)\r\n      end\r\n   end \r\n   hold off\r\nend\r\n\r\nend<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>function [node_xy,elem_node] = ElemQ4(L,H,m,n,varargin) % ====================================================% % function to create Q4 elements (2D) % % INPUT: % % &gt; length (L) and height (H), % % &gt; division over x (m) and division over y (n) % % &gt; option for plotting (varargin) % % OUTPUT: % % &gt; coordinate of nodes [node_xy] % % [&hellip;]<\/p>\n","protected":false},"author":6455,"featured_media":1262,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-1261","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-matlab"],"_links":{"self":[{"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/posts\/1261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/users\/6455"}],"replies":[{"embeddable":true,"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/comments?post=1261"}],"version-history":[{"count":6,"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/posts\/1261\/revisions"}],"predecessor-version":[{"id":1274,"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/posts\/1261\/revisions\/1274"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/media\/1262"}],"wp:attachment":[{"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/media?parent=1261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/categories?post=1261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/people.utm.my\/arazin\/wp-json\/wp\/v2\/tags?post=1261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}