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!