How to change this for loop into parfor loop?
古いコメントを表示
Hi guys, I'm new to the MATLAB. I am currently trying to change a for loop into a parfor loop, but after many attempts altering my codes, I still cannot seem to make it work. I either get variable classification issue or I get transparency issue. I hope that someone can help me translate my codes into a parfor loop. Here are the codes:
% Removing colums of data with y consecutive data points that have same values with in each column. data.txt consist of a n by m matrix with the first row being names.
load data.txt
nrow=size(data,1);
ncol=size(data,2);
y=10;
for j = 1:1:ncol
i = 2;
while i <= nrow - (y - 1)
if data(i,j) == data(i+1,j)
data_vec = data(i:i+y-1,j);
diff_vec = data_vec(2:end,1) - data_vec(1:end-1,1);
temp = sort(diff_vec);
if temp(1,1) ==0 && temp(end,1) == 0
data(:,j) = 0;
i = nrow;
else
i = i + find(diff_vec,1) - 1;
end
clearvars temp data_vec diff_vec
end
i = i + 1;
end
end
data( :, ~any(data,1) ) = [];
clearvars nrow ncol j i
Thank you for your help in advance :).
採用された回答
その他の回答 (1 件)
カテゴリ
ヘルプ センター および 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!