Replace string and then place it again
Mostrar comentarios más antiguos
Hey, I want to make the output return # as many times as a certain string has, and then, change each # with the corresponding letter in the original string to get a cool ouput.
This is my code so far but I got stuck:
function a = jamstr(strd,time)
for i = 0:1:length(strd)
z = i + 1;
expression = '^.*';
replace = '#';
newStr = regexprep(strd(z),expression,replace)
fprintf(newStr);
pause(time);
a=z;
if z == length(strd)
break
end
end
end
3 comentarios
BobH
el 9 de Mzo. de 2020
I'm having difficulty understanding what you're asking.
- what would a sample 'strd' look like?
- what do you want the corresponding 'a' to look like?
Mansour Al Asais
el 18 de Mzo. de 2020
Ameer Hamza
el 18 de Mzo. de 2020
Editada: Ameer Hamza
el 18 de Mzo. de 2020
Mansour, what is the expected output for
jamstr('Matlab rocks!',0.1)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!