필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
TheSaint
TheSaint 2024년 2월 1일
댓글: TheSaint 2024년 2월 2일
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)

채택된 답변

Voss
Voss 2024년 2월 1일
CarNumber = input('Please enter the car number: ');
fprintf('Car number %d is driving the fastest\n', CarNumber);
  댓글 수: 2
Walter Roberson
Walter Roberson 2024년 2월 1일
Or
fprintf("Car number " + CarNumber + " is driving the fastest\n")
TheSaint
TheSaint 2024년 2월 2일
Thanks Walter, this worked for me

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by