how to solve multiple iteration for multiple input?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sivalogan satchithanandamoorthy
el 27 de Jul. de 2017
Respondida: Abhi Sundararaman
el 1 de Ag. de 2017
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
0 comentarios
Respuesta aceptada
Abhi Sundararaman
el 1 de Ag. de 2017
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 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!