0

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.

1 Answer 1

3

You can get a boolean vector of all elements that are -1 by y1==-1 and substitute them for 0:

y2( y2 == -1 ) = 0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.