Reputation: 45
I have a set of data columns extracted using textscan from code shown below:
fid = fopen('wam1.txt','r');
C = textscan(fid,'%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f','headerlines',4,'commentstyle','--');
fclose(fid);
x = C{1}; y1 = C{5}; y2 = C{3};
For major part of the column y1 & y2, I have negative value of -1, where no reading was taken. My task is to substitute these -1 values in the columns with 0.
I tried using changem
but I can't seem to get it working.
Can someone help please.
Upvotes: 0
Views: 867
Reputation: 4713
You can get a boolean vector of all elements that are -1 by y1==-1
and substitute them for 0:
y2( y2 == -1 ) = 0
Upvotes: 3