Jorge Zapata
Jorge Zapata

Reputation: 2336

Logical to char

I have a char array representing a binary number for example

bit <1x8 char> '00110001'

I want to replace the last char with a logical value. The following error is triggered: Conversion to char from logical is not possible.

This is my code:

bit(end:end) = hiddenImg(i,j);

I checked that hiddenImg(i,j) is in fact a logical value.

Upvotes: 2

Views: 4683

Answers (1)

tmpearce
tmpearce

Reputation: 12693

This may not be optimal but should do what you want (convert the logical to a char):

>> bit = '10010100'

bit =

10010100

>> bit(end)=num2str(true)

bit =

10010101

Upvotes: 2

Related Questions