How can i perform the for loop in this case?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi ,
i try to perform for loop but doesnt work as well ,the idea is my data is 153*1 i have exracted it from 3d array because in my project the data must be column vector but ihave to run for loop along 71 trace in the horizontal axis so first 153*1 at first position the next iteration must be at the second an so on and must be mantain the same dimension until 71 i hope i was clear enough,any suggestons please.
댓글 수: 7
Voss
2021년 12월 5일
@RADWAN A F ZEYADI: OK, I have the code. Please describe the problem you are facing, and refer to variables by name. Is d_obs the 3d array you mention?
답변 (1개)
Mathieu NOE
2021년 12월 6일
hello
not sure to have 100% understood the question but maybe this answer it ?
I,believe it's simply about reshaping data - either with for loop or with reshape ...
%% dummy data
data = 1:1:1000; % data
buffer = 153; % nb of samples
%% solution 1
m = length(data);
data = data(:); % convert data to col vector
k = fix(m/buffer);
data = data(1:k*buffer); % we can only process multiple of "buffer" size data length.
for ci=1:k
start_index = 1+(ci-1)*buffer;
stop_index = min(start_index+ buffer-1,m);
out_data(:,ci) =data(start_index:stop_index);
end
%% solution 2
m = length(data);
data = data(:); % convert data to col vector
k = fix(m/buffer);
data = data(1:k*buffer); % we can only process multiple of "buffer" size data length.
out_data2 = reshape(data,buffer,[]);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!