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

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)

 Risposta accettata

CarNumber = input('Please enter the car number: ');
fprintf('Car number %d is driving the fastest\n', CarNumber);

2 Commenti

Or
fprintf("Car number " + CarNumber + " is driving the fastest\n")
Thanks Walter, this worked for me

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Centro assistenza e File Exchange

Prodotti

Release

R2023b

Richiesto:

il 1 Feb 2024

Commentato:

il 2 Feb 2024

Community Treasure Hunt

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

Start Hunting!

Translated by