You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
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 view (last 30 days)
Show older comments
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 Comment
Accepted Answer
madhan ravi
on 24 Oct 2018
Edited: madhan ravi
on 24 Oct 2018
a=repelem(ey.', 3, 1)
a= reshape(a,3,3) %and then multiply a with repmat
A=repmat(N_dash, 3, 1) .* a
26 Comments
Virajan Verma
on 24 Oct 2018
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
on 24 Oct 2018
%%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
on 24 Oct 2018
>> COMMUNITY
Undefined function or variable 'y'.
Error in COMMUNITY (line 9)
my=(y(5)-y(2));
>>
madhan ravi
on 24 Oct 2018
Edited: madhan ravi
on 24 Oct 2018
whats x,y ,s and z ? provide the values
Virajan Verma
on 24 Oct 2018
I have a separate input file for that. U can take any decimal values like 0.9821,0.8736 etc
madhan ravi
on 24 Oct 2018
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
on 24 Oct 2018
It works I made slight modification also I assumed value of s as 4(if it matters)
Virajan Verma
on 24 Oct 2018
Edited: Walter Roberson
on 24 Oct 2018
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
on 24 Oct 2018
Edited: madhan ravi
on 24 Oct 2018
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
on 24 Oct 2018
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
on 24 Oct 2018
Edited: madhan ravi
on 24 Oct 2018
B_matrix=(1/s)*repmat(N_dash, 3, 1) .* A
madhan ravi
on 24 Oct 2018
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
on 24 Oct 2018
if you got the answer for your question accept the answer so people know the question is solved
Virajan Verma
on 24 Oct 2018
I have not got the desired result yet, otherwise i would have done that.
madhan ravi
on 24 Oct 2018
Edited: madhan ravi
on 24 Oct 2018
whats your desired result and its size ?
madhan ravi
on 25 Oct 2018
Edited: madhan ravi
on 25 Oct 2018
Really really glad that I was able to help because you were struggling for days with this problem.
Virajan Verma
on 25 Oct 2018
Yes i was really struggling. Its people like u who support others. Really thanks for ur valuable suggestions and time.
More Answers (0)
See Also
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)