Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Function SAVE is saving repeatly results - HOW TO SOLVE IT?
Replies: 0

 Ana Beatriz Posts: 6 Registered: 6/17/14
Function SAVE is saving repeatly results - HOW TO SOLVE IT?
Posted: Jul 8, 2014 7:11 AM

Hi all,
I'm changing some values from my datasets to NaN and saving again. However, the final ascii files have much more lines that the variables. For example: the variable Data10 and Data10_mod have 107342x3 double, whilst the final ascii file Data10_mod has 807412x3.
I'm copying my code below. Please, could someone help me to find the mistake? How do I solve this?

Thank you!!
Beatriz

%Load bathymetry 2010 and separate the columns into three different
%unknowns
X10 = Data10(:,1);
Y10 = Data10(:,2);
Z10 = Data10(:,3);

%Load bathymetry 2011 and separate the columns into three different
%unknowns
X11 = Data11(:,1);
Y11 = Data11(:,2);
Z11 = Data11(:,3);

%Select the minumim of the two maximums and the maximum of the two minimums
minZ = max(min(Z10),min(Z11));
maxZ = min(max(Z10),max(Z11));

%Find values lower than the minimum and higher than the maximum
%Replace by NaN
I = find(Z10 < minZ);
if isempty(I) == 0 %means if I has values
Z10(I)=NaN;
end

I = find(Z10 > maxZ);
if isempty(I) == 0
Z10(I)=NaN;
end

I = find(Z11 < minZ);
if isempty(I) == 0
Z11(I)=NaN;
end

I = find(Z11 > maxZ);
if isempty(I) == 0
Z11(I)=NaN;
end

%Create two new matrixes with the new values
Data10_mod = [X10 Y10 Z10];
Data11_mod = [X11 Y11 Z11];

%Save using ASCII save function
save('Data10_mod','-ascii','-double','-tabs');
save('Data11_mod','-ascii','-double','-tabs');