Borrar filtros
Borrar filtros

How do I put a variable input inside a char vector?

1 visualización (últimos 30 días)
TheSaint
TheSaint el 1 de Feb. de 2024
Comentada: TheSaint el 2 de Feb. de 2024
fprintf('Car number' 'is driving the fastest', x)
I have this function, and I want to put an input command such as this in between 'Car number' and 'is driving...'
CarNumber = input('Please enter the car number')
Is there a way I can do this? I tried using this line below, but it was unsuccessful
fprintf('Car number'CarNumber 'is driving the fastest', x)

Respuesta aceptada

Voss
Voss el 1 de Feb. de 2024
CarNumber = input('Please enter the car number: ');
fprintf('Car number %d is driving the fastest\n', CarNumber);
  2 comentarios
Walter Roberson
Walter Roberson el 1 de Feb. de 2024
Or
fprintf("Car number " + CarNumber + " is driving the fastest\n")
TheSaint
TheSaint el 2 de Feb. de 2024
Thanks Walter, this worked for me

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by