How can i perform the for loop in this case?

2 ビュー (過去 30 日間)
RADWAN A F ZEYADI
RADWAN A F ZEYADI 2021 年 12 月 4 日
回答済み: Mathieu NOE 2021 年 12 月 6 日
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
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?
RADWAN A F ZEYADI
RADWAN A F ZEYADI 2021 年 12 月 6 日
@Benjamin yes d_obs is 3d array must be 153*1 and i have to perfurm for loop in along horizontal axis for 71 positions so 153*1 at 1st iteration and 2nd 153*1 in the 2nd position an so on d_obs(:,1,:) in this way but if you see in the input of the function Esmda_inv d_obs must be 153*1 so the forloop before the esmda_inv function

サインインしてコメントする。

回答 (1 件)

Mathieu NOE
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,[]);

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by