I am writing an FEM code in matlab. I want to make the sizes of repmat(N_dash, 3, 1) and repelem(ey.', 3, 1) the exact same. Original size of repmat(N_dash, 3, 1) is 3x3 and that of repelem(ey.', 3, 1) is 9x1. Any help will be much appreciated.
1 次查看(过去 30 天)
显示 更早的评论
for epsilon3=-1:1:1
N_dash(1)=-0.5+epsilon3;
N_dash(2)=-2*epsilon3;
N_dash(3)=0.5+epsilon3;
end
ly=(x(5)-x(2)); (x,y,z are constants like 0.9876,0.8876..etc)
my=(y(5)-y(2));
ny=(z(5)-z(2));
lve=sqrt(((ly)^2)+((my)^2)+((ny)^2)); %%vertical length of element
ey = [ly; my; ny] / lve;
A=repmat(N_dash, 3, 1) .* repelem(ey.', 3, 1)
1 个评论
采纳的回答
madhan ravi
2018-10-24
编辑:madhan ravi
2018-10-24
a=repelem(ey.', 3, 1)
a= reshape(a,3,3) %and then multiply a with repmat
A=repmat(N_dash, 3, 1) .* a
26 个评论
Virajan Verma
2018-10-24
Still getting the same error, though i have used size and numel command and sizes and no. of elements are same. I dont know what is the problem. The LHS of eqaution is B_matrix(1,1:8) which is defined as:
for i=1:8
for j=1:26
B_matrix(i,j)=0;
end
end
Virajan Verma
2018-10-24
%%Strain for the (Axial) Extensional Flexural Effects
for epsilon3=-1:1:1
N_dash(1)=-0.5+epsilon3;
N_dash(2)=-2*epsilon3;
N_dash(3)=0.5+epsilon3;
end
(TAKE ANY CONSTANT VALUE OF x,y,z like 0.8798,0.3456)
%%Tangent vector (ey) about y dirsction
ly=(x(5)-x(2));
my=(y(5)-y(2));
ny=(z(5)-z(2));
lve=sqrt(((ly)^2)+((my)^2)+((ny)^2)); %%vertical length of element
ey = [ly; my; ny] / lve;
for i=1:8
for j=1:26
B_matrix(i,j)=0;
A=reshape(repmat(ey, 3, 1),3,3)
for i=1:8
B_matrix(1,1:8)=1/s*repmat(N_dash, 3, 1) .* A
end
end
end
madhan ravi
2018-10-24
>> COMMUNITY
Undefined function or variable 'y'.
Error in COMMUNITY (line 9)
my=(y(5)-y(2));
>>
Virajan Verma
2018-10-24
I have a separate input file for that. U can take any decimal values like 0.9821,0.8736 etc
madhan ravi
2018-10-24
for epsilon3=-1:1:1
N_dash(1)=-0.5+epsilon3;
N_dash(2)=-2*epsilon3;
N_dash(3)=0.5+epsilon3;
end
% (TAKE ANY CONSTANT VALUE OF x,y,z like 0.8798,0.3456)
%%Tangent vector (ey) about y dirsction
ly=2-5;
my=7+18;
ny=4;
lve=sqrt(((ly)^2)+((my)^2)+((ny)^2)); %%vertical length of element
ey = [ly; my; ny] / lve;
for i=1:8
for j=1:26
B_matrix(i,j)=0;
A=reshape(repmat(ey, 3, 1),3,3)
B_matrix=1/4*repmat(N_dash, 3, 1) .* A
end
end
madhan ravi
2018-10-24
It works I made slight modification also I assumed value of s as 4(if it matters)
Virajan Verma
2018-10-24
编辑:Walter Roberson
2018-10-24
x1=0
y1=0
z1=0
x2=0.5
y2=0
z2=0.049406182
x3=1
y3=0
z3=0.097122055
x5=0.5
y5=0.51
z5=0.049406182
for i=-1:1:1
epsilon3=(i)
lx=(epsilon3-0.5)*x(1)-(2*epsilon3)*x(2)+(epsilon3+0.5)*x(3);
mx=(epsilon3-0.5)*y(1)-(2*epsilon3)*y(2)+(epsilon3+0.5)*y(3);
nx=(epsilon3-0.5)*z(1)-(2*epsilon3)*z(2)+(epsilon3+0.5)*z(3);
%%Jacobian Factor
s=sqrt(((lx)^2)+(((mx)^2)+(((nx)^2))));
madhan ravi
2018-10-24
编辑:madhan ravi
2018-10-24
x(1)=0
y(1)=0
z(1)=0
x(2)=0.5
y(2)=0
z(2)=0.049406182
x(3)=1
y(3)=0
z(3)=0.097122055
x(5)=0.5
y(5)=0.51
z(5)=0.049406182
epsilon3=-1:1:1
for i=1:numel(epsilon3)
lx(i)=(epsilon3(i)-0.5)*x(1)-(2*epsilon3(i))*x(2)+(epsilon3(i)+0.5)*x(3);
mx(i)=(epsilon3(i)-0.5)*y(1)-(2*epsilon3(i))*y(2)+(epsilon3(i)+0.5)*y(3);
nx(i)=(epsilon3(i)-0.5)*z(1)-(2*epsilon3(i))*z(2)+(epsilon3(i)+0.5)*z(3);
end
%%Jacobian Factor
s=0.5025;
% (TAKE ANY CONSTANT VALUE OF x,y,z like 0.8798,0.3456)
%%Tangent vector (ey) about y dirsction
lve=sqrt(((ly)^2)+((my)^2)+((ny)^2)); %%vertical length of element
ey = [ly; my; ny] / lve;
for i=1:8
for j=1:26
B_matrix(i,j)=0;
A=reshape(repmat(ey, 3, 1),3,3)
B_matrix=(1/s)*repmat(N_dash, 3, 1) .* A
end
end
Virajan Verma
2018-10-24
But i am getting this error: Subscripted assignment dimension mismatch.
Error in practisee2 (line 225) B_matrix(1,1:9)=1/s*repmat(N_dash, 3, 1) .* A
madhan ravi
2018-10-24
replace
B_matrix(1,1:9)=(1/s)*repmat(N_dash, 3, 1) .* A
with
B_matrix=(1/s)*repmat(N_dash, 3, 1) .* A
madhan ravi
2018-10-24
if you got the answer for your question accept the answer so people know the question is solved
madhan ravi
2018-10-25
编辑:madhan ravi
2018-10-25
Really really glad that I was able to help because you were struggling for days with this problem.
Virajan Verma
2018-10-25
Yes i was really struggling. Its people like u who support others. Really thanks for ur valuable suggestions and time.
更多回答(0 个)
另请参阅
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)