Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Storing error values every iteration

조회 수: 1 (최근 30일)
Griffin Polglaze
Griffin Polglaze 2020년 5월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
I need to store the error value after every completed iteration. I've tried to do this using the following section of code, however instead of storing the error, err_every_iter stores a matrix containing n iterations. Any help would be greatly appreciated
iter_error = max(abs(T - T_c));
T_c = T;
if iter_error < error_max
break;
end
err_every_iter = iter_error;
err_every_iter = [1:n];

답변 (1개)

Pravin Jagtap
Pravin Jagtap 2020년 5월 4일
Hello Griffin,
Please refer to the last two lines of the code:
err_every_iter = iter_error; % iter_error is stored here
err_every_iter = [1:n]; % again err_every_iter is replaced with [1:n]
Here, you are updating the values in 'error_every_iter' twice (read the comments above). I think as per your requirement, you need 'err_every_iter' array which you need to update inside the 'for loop' for every iteration as follows:
err_every_iter(i) = iter_error % i represents the iterator of for loop
Hope this will help.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by