how to solve multiple iteration for multiple input?

조회 수: 4 (최근 30일)
sivalogan satchithanandamoorthy
sivalogan satchithanandamoorthy 2017년 7월 27일
답변: Abhi Sundararaman 2017년 8월 1일
I want to solve this equation ∆ε=∆σ/E+2(∆σ/2k)^n for ∆σ using iteration. I have ε ranging from (0 to 2).
  • ∆ε is elongation
  • ∆σ is stress
  • E is modulus of elasticity
  • K and n are constant
x = 16; %x is ∆σ
x_old = 100;
iter = 0;
k=38.177;
n=7.22;
E=15.25;
% y=linspace(0,5,0.5);
for i=[0:.01:0.5]
while abs(x_old-x) > 10^-3 && x ~= 0
x_old = x;
x = x - (2*(x/(2*k))^(n) + (x/(E))-i)/(2*n*(x/(2*k))^(n-1) + (1/(E)));
iter = iter + 1;
fprintf('Iteration %d: x=%.20f\n', iter, x);
pause;
end
end
I have script for Newton-Raphson Method for finding out ∆σ, but i don't know know how solve for multiple values. what i mean by multiple value is i have different ∆ε, ranging from 0 to 2. once i solved the iteration, i want to plot it as well. I think i could figure out ploting, but it would be helpful, if you could guide me on this. thank you very much!
sincerely siva

채택된 답변

Abhi Sundararaman
Abhi Sundararaman 2017년 8월 1일
You could create another for loop outside your "while" loop that changes epsilon during each iteration. Then you substitute this value of epsilon into your iteration equation inside your while loop. For example,after initializing your constants,
x = 16; %guess for x
Epsilon = 0:0.1:2
Sigma = zeros(size(Epsilon));
i = 1;
for Epsilon = 0:0.1:2
x = 16; %reinitialize the guess for x
while abs(x_old - x) > 10^-3 && x ~= 0
<insert your iteration equation here, with Epsilon included>
<solve for sigma (x)>
end
Sigma(i) = x;
i = i + 1;
end
plot( Epsilon, Sigma );

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by