필터 지우기
필터 지우기

My plot won't show any graph

조회 수: 2 (최근 30일)
Steve
Steve 2020년 12월 14일
편집: VBBV 2020년 12월 14일
I try to plot the data i get from step below. But My plot doesn't have any data. Just a clean sheet. Can anyone tell which part I'm wrong
clear
%%Given :
T= 5;
del_t=0.5;
t=0:del_t:T;
E=5;
v=0.3;
Sya=25;
Sy=15;
d=0.4;
vis=0;
gamma=0;
%Assume :
epn=0;
alfa=0;
DevS=0;
M= E/(2*(1+v));
L= (E*v)/[(1+v)*(1-2*v)];
G = norm(DevS)-sqrt(2/3)*Sy+(Sya-Sy)*(1-exp(-d*alfa))-[M*gamma*2];
Gd=-2*M*(1+(Sya-Sy)*d*exp(-d*gamma));
for n = 1:length(t);
strain=6*n*[1 0 0; 0 1 0; 0 0 1]+6*sin(n)*[0 2 0; 2 1 0; 0 0 3/2];
el=strain-(1/3)*trace(strain)*eye(3,3);%
DevStrial=DevS+2*M*(el-epn); %Devatoric Stress Trial
etrial=DevStrial;
y=Sy+(Sya-Sy)*(1-exp(-d*alfa));
ftrial=norm(DevS)-sqrt(2/3)*y;
if ftrial<=0;
DevS=DevStrial;
else
while and((abs((G/Gd)/gamma)) >= 0.001, gamma==0);
%g[dγ(k)]
G = ftrial-[M*gamma*2];
%Dg[dγ(k)]
Gd=-2*M*(1+(Sya-Sy)*d*exp(-d*gamma));
gamma= gamma - G/Gd;
% Derivative of yield limit function: K'(α)
end
del_g= gamma;
normal=etrial/norm(etrial);
alfa=alfa+sqrt(2/3)*del_g;
%Update back stress, plastic strain, and stress
epn=epn+del_g*normal;
k = L+(2/3)*M;
S=k*trace(strain)*eye(3,3)+DevStrial-2*M*del_g;
% Compute consistent elastoplastic tangent moduli
A=eye(3,3);
B=eye(6,6);
Cp=1/3*kron(A,A)-kron(normal,normal);
end
end
figure
hold on
plot(t,S(1:1,1:1),'linewidth',5,'color','r')
plot(t,S(2:2,2:2),'linewidth',5,'color','r')
plot(t,S(3:3,3:3),'linewidth',5,'color','r')
legend('s11','s22','s33')
plot(t, alfa ,'linewidth',5,'color','r')
xlabel( 'Time', 'FontSize', 16)
ylabel( 'alfa', 'FontSize', 18)
grid on
figure
hold on
plot(t,Cp(1:1,1:1),'linewidth',5,'color','r')
plot(t,Cp(4:4,4:4),'linewidth',5,'color','r')
plot(t,Cp(5:5,5:5),'linewidth',5,'color','r')
legend('s1','s2','s3')

채택된 답변

VBBV
VBBV 2020년 12월 14일
편집: VBBV 2020년 12월 14일
clear
%%Given :
T= 5;
del_t=3;
t=linspace(0,T,del_T);
E=5;
v=0.3;
Sya=25;
Sy=15;
d=0.4;
vis=0;
gamma=0;
%Assume :
epn=0;
alfa=zeros(size(t));
DevS=0;
M= E/(2*(1+v));
L= (E*v)/[(1+v)*(1-2*v)];
G = norm(DevS)-sqrt(2/3)*Sy+(Sya-Sy)*(1-exp(-d*alfa))-[M*gamma*2];
Gd=-2*M*(1+(Sya-Sy)*d*exp(-d*gamma));
for n = 1:length(t);
strain=6*n*[1 0 0; 0 1 0; 0 0 1]+6*sin(n)*[0 2 0; 2 1 0; 0 0 3/2];
el=strain-(1/3)*trace(strain)*eye(3,3);%
DevStrial=DevS+2*M*(el-epn); %Devatoric Stress Trial
etrial=DevStrial;
y=Sy+(Sya-Sy)*(1-exp(-d*alfa));
ftrial=norm(DevS)-sqrt(2/3)*y;
if ftrial<=0;
DevS=DevStrial;
else
while and((abs((G/Gd)/gamma)) >= 0.001, gamma==0);
%g[dγ(k)]
G = ftrial-[M*gamma*2];
%Dg[dγ(k)]
Gd=-2*M*(1+(Sya-Sy)*d*exp(-d*gamma));
gamma= gamma - G/Gd;
% Derivative of yield limit function: K'(α)
end
del_g= gamma;
normal=etrial/norm(etrial);
alfa(n)=alfa(n)+sqrt(2/3)*del_g;
%Update back stress, plastic strain, and stress
epn=epn+del_g*normal;
k = L+(2/3)*M;
S=k*trace(strain)*eye(3,3)+DevStrial-2*M*del_g;
% Compute consistent elastoplastic tangent moduli
A=eye(3,3);
B=eye(6,6);
Cp=1/3*kron(A,A)-kron(normal,normal);
end
end
% figure plots
figure(1)
plot(t,S(1:3,1:3),'linewidth',5,'color','r')
legend('s11','s22','s33')
hold on
plot(t, alfa ,'linewidth',5,'color','r')
xlabel( 'Time', 'FontSize', 16)
ylabel( 'alfa', 'FontSize', 18)
grid on
figure(2)
plot(t,Cp(1:3,1:3),'linewidth',5,'color','r')
legend('s1','s2','s3')

추가 답변 (1개)

Jan
Jan 2020년 12월 14일
I assume, this is an effect or drawing a line with just 1 point, which produces no line.
Try
plot(t, S(1,1), 'linewidth', 5, 'color', 'r', 'Marker', 'o')
  댓글 수: 2
Steve
Steve 2020년 12월 14일
It still doesn't work, the S function is a matrix 3x3, and I want to plot the value of the first row and first column when t=0 till t=5
Jan
Jan 2020년 12월 14일
편집: Jan 2020년 12월 14일
The first row is S(1, :), not S(1:1, 1:1).
What about:
plot(t,S,'linewidth',5,'color','r')

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by