Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
change 0 and 1

Subject: change 0 and 1

From: Wendy

Date: 28 Jan, 2010 15:09:04

Message: 1 of 2

Hi all,

If I have a vector
a=[0 1 0 0 1];

I want change it to
b=[1 0 1 1 0];

Is there a function for that in matlab?

Thank you in advance,
W.

Subject: change 0 and 1

From: Steven Lord

Date: 28 Jan, 2010 15:12:45

Message: 2 of 2


"Wendy " <wlq121@gmail.com> wrote in message
news:hjs9ag$iue$1@fred.mathworks.com...
> Hi all,
>
> If I have a vector a=[0 1 0 0 1];
>
> I want change it to b=[1 0 1 1 0];
>
> Is there a function for that in matlab?

Either use NOT (if you're okay with b being a logical array) or MINUS with a
as one of the inputs (if you want b to be a double array.)

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us