it says error using assert, assertion failed and error in iuntitled (line 10) assert(ischar(in))

36 visualizaciones (últimos 30 días)
error using assert
Assertion failed
Error in iuntitled (line 10)
  3 comentarios

Iniciar sesión para comentar.

Respuestas (2)

Geoff Hayes
Geoff Hayes el 17 de Jun. de 2022
@Ian - as per the function comment, Encode a single character i. I suspect that you are passing something else i.e. a numeric value like
>> encodeCharacter(42)
Error using encodeCharacter (line 8)
Assertion failed.
Try doing
>> encodeCharacter('4')
ans =
or any other character. Note that you can only pass in one character. If you pass in 2 or more, then a different assert will fire.

Cris LaPierre
Cris LaPierre el 17 de Jun. de 2022
That is what an assert does. If the assertion fails (here that means that in is not a char), then an error is thrown and the message 'Assertion failed.' is thrown.
% Assertion is true -> no error
in = '5';
% Assertion is false -> error
in = 5;
Error using assert
Assertion failed.


Más información sobre Extend Unit Testing Framework en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by