s = "Matlab rocks";
fprintf (s(3));
Index exceeds the number of array elements. Index must not exceed 1.
Error (line 2)
fprintf (s(3));

Respuestas (1)

KSSV
KSSV el 24 de Mzo. de 2022

0 votos

s = "Matlab rocks";
fprintf ('%s\n',s);
Matlab rocks

4 comentarios

Kyara Christelle Riguerra
Kyara Christelle Riguerra el 24 de Mzo. de 2022
What if I want to get the 3rd character in the string? Thanks.
KSSV
KSSV el 24 de Mzo. de 2022
s = "Matlab rocks";
s{1}(3)
ans = 't'
KSSV
KSSV el 24 de Mzo. de 2022
s = "Matlab rocks";
sc = char(s) ;
sc(3)
ans = 't'
Kyara Christelle Riguerra
Kyara Christelle Riguerra el 24 de Mzo. de 2022
Thanks!

Iniciar sesión para comentar.

Categorías

Preguntada:

el 24 de Mzo. de 2022

Comentada:

el 24 de Mzo. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by