How to insert a string into a sprint?

4 ビュー (過去 30 日間)
JOJO
JOJO 2013 年 12 月 22 日
コメント済み: Image Analyst 2013 年 12 月 23 日
I want the input stored into name be displayed in the %s. How can I do it? it is possible?
name = input ('Enter the name of the voice command');
file = sprintf('%s.wav','name'); %name the sound file to be created

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 22 日
name = input ('Enter the name of the voice command','s');
file = sprintf('%s.wav',name);

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 12 月 22 日
Try this more user friendly and robust way to "get the name of the sound file to be created":
% Ask user for the name of the file to be created.
[baseFileName, folder] = uiputfile('*.wav', 'Enter the file name of the voice command to be created')
% Create the full file name with the folder prepended.
% .wav will be automatically appended regardless
% if they did or did not enter an extension.
fullFileName = fullfile(folder, baseFileName)
  1 件のコメント
Image Analyst
Image Analyst 2013 年 12 月 23 日
By the way, Walter already suggested that you use fullfile in this answer to your previous question

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeJust for fun についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by