How to store every iteration value

조회 수: 1 (최근 30일)
Eagle
Eagle 2013년 10월 10일
편집: Eagle 2013년 10월 12일
I need to run the code for iteration=20000 times and i need to store the value of "D" for every trial.I run this code only one time,But if i want to run this code for 20000 time then how can store every iteration value.I need to store only "D" value.
Matlab experts need your help and suggestion.

답변 (1개)

cr
cr 2013년 10월 10일
1. You dont have to write a loop to get difference values. Just do diff(D). Or, before you do rec2_Wopt(1) = rec2_Wopt(1) + sum(RecP), create a D2(count,:) = rec2_Wopt(1)/Trial (not sure if I understood what you are doing, so check it. The point is, just save the D vector before you do a cumulative sum inside the loop).
2.You will have to wrap the entire code inside another loop and need to create a 3-dimensional matrix for D, where, in the third dimension you will store the D matrix at every iteration. Then, you will be doing D(count,:,iter) = ... where iter runs from 1:20000
Preallocate memory for D if you use such big loops. Also check if loops are avoidable and if you can do it by vector ops.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by