why this loop is not working? Actually p_j value is not changing why?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
n = input('please enter number of strips :');
for i = 1:n
for j = i
p_i = 0
p_j = p_i + D/(2*n)
epsilon_ci = (epsilon_max/xu)*(xu-p_j)
sigma_ci = 0.45*fc*[2*(epsilon_ci/0.002)-(epsilon_ci/0.002)^2]
p_i == p_j;
end
end
2 Kommentare
Dyuman Joshi
am 5 Mär. 2023
Bearbeitet: Dyuman Joshi
am 5 Mär. 2023
"why this loop is not working?"
It is working.
"Actually p_j value is not changing why?"
Because you are over-writing p_j with every iteration.
It is difficult to make any suggestions as it is not clear what you are trying to do. Format your code properly, mention values of variables and specify what you want to do with this code.
Walter Roberson
am 5 Mär. 2023
p_i == p_j;
That is not an assignment statement
Antworten (2)
VBBV
am 8 Mär. 2023
Bearbeitet: VBBV
am 8 Mär. 2023
n = 10;% e.g. input number
epsilon_ci = 0.001;
epsilon_max = 0.01;
xu = 2;
fc = 100;
D = 1.1;
p_i = 0; %outside for loop
for i = 1:n
p_j(i) = p_i + D/(2*n);
epsilon_ci = (epsilon_max/xu)*(xu-p_j(i));
sigma_ci = 0.45*fc*(2*(epsilon_ci/0.002)-(epsilon_ci/0.002)^2);
p_i = p_j(i); % assign new p_i
end
p_j
1 Kommentar
VBBV
am 8 Mär. 2023
You require only one for loop, since the inner for loop will lead to only one iteration,
Siehe auch
Kategorien
Mehr zu Denoising and Compression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!