MATLAB Answers

Make a loop using squeeze function

5 views (last 30 days)
Paulo Eduardo Beiral
Paulo Eduardo Beiral on 22 Oct 2019
Commented: Daniel M on 23 Oct 2019
Hey all,
I've got something about 2000 files variables named turb (dimension 2112 x 2688), and what I need is to remove all the values from those turb variables greater than (x + 3*std). This thing I'm able to do in my script.
What I need help is that, when it's done, matlab generates a 3D variable y (2000 x 2112 x 2688). So I've got to use the squeze function to split this y variable in 2000 filtered matrixes 2112 x 2688, and I guess I'd need to make a "for" loop whith the squeeze function, but I don't know how to do it....
Any help with this would be really aprecciated and really helpfull...
Regards, Paulo Beiral.
diret = '/mnt/cerberus/Sensoriamento/paulo_beiral/teste';
cd (diret);
files = './*.mat';
dir (files);
arrumado = dir(files);
files = [1 355];
%% Filtering
for i = 1:length(arrumado)
if str2double(arrumado(i).name(6:8)) >= files(1) && str2double(arrumado(i).name(6:8)) <= files(2)
T(i) = load(arrumado(i).name);
y = {T.turb};
y = cellfun(@(y) shiftdim(y,-1),y,'UniformOutput',false)';
y = cell2mat(y);
y(y > x+3*std) = NaN;
separating = squeeze(y(1,:,:)); %% THIS IS THE LINE THAT HAS TO BE IMPROVED!!


Daniel M
Daniel M on 22 Oct 2019
You're saying you want to make 2000 variables, each is 2112x2688 in size?
Why though? This is horrible impractical.
Paulo Eduardo Beiral
Paulo Eduardo Beiral on 23 Oct 2019
Why do you say it's impractical?
Is matlab software not capable or doesn't support such a thing?
I need to do it because these 2000 variables are diary variables of turbidity since 2003, and for my research I need those variables statiscaly corrected....
Are you really sure this is a impossible thing to be done in matlab?
Thanks for your time!
Daniel M
Daniel M on 23 Oct 2019
I'm just trying to understand how you intend to use the 2000 variables. Do you just want to save 2000 variables separately? Or do you intend to actively work with 2000 variables in your code?
In either case, you do not need to create 2000 variables.

Sign in to comment.

Answers (0)

Sign in to answer this question.

Translated by