필터 지우기
필터 지우기

Plotting using a for loop

조회 수: 1 (최근 30일)
alexrecai
alexrecai 2021년 3월 19일
댓글: alexrecai 2021년 3월 19일
Hello, I'm having a difficulty plotting the results using a for loop. I want to plot epsilon vs sigma but I get the following error: Array indices must be positive integers or logical values. Can you please help me? Thank you.
E=200*10^9; %Pa Elastic Modulus
v= 0.28; %Poisson's Ratio
eps=linspace(0,0.1,1000);
Y= 375.8;
m=2000;
n=0.5;
for i= 1:1000
sigma(i)=Y(1+m*eps(i)^n)
end
eps=[0 eps];
plot(eps,sigma)

채택된 답변

Alan Stevens
Alan Stevens 2021년 3월 19일
Like so:
E=200*10^9; %Pa Elastic Modulus
v= 0.28; %Poisson's Ratio
eps=linspace(0,0.1,1000);
Y= 375.8;
m=2000;
n=0.5;
for i= 1:1000
sigma(i)=Y*(1+m*eps(i)^n); % You need a multiply sign between Y and what follows it.
end
% eps=[0 eps]; You don't need this.
plot(eps,sigma)
  댓글 수: 1
alexrecai
alexrecai 2021년 3월 19일
Oh, I didn't notice that. Thank you very much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by