How can i perform the for loop in this case?

2 Ansichten (letzte 30 Tage)
RADWAN A F ZEYADI
RADWAN A F ZEYADI am 4 Dez. 2021
Beantwortet: Mathieu NOE am 6 Dez. 2021
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 Kommentare
Voss
Voss am 5 Dez. 2021
@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 am 6 Dez. 2021
@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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Mathieu NOE
Mathieu NOE am 6 Dez. 2021
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,[]);

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by