How do I retain quotation marks around a file path when using it in another string?

I have a script where one of the outputs is multiple csv files of data, however the command to store the data requires the file path to be in quotes.
localStorage = 'D:\myFilepath'
localCSV = fullfile(localStorage, 'myFile.csv');
sprintf(":MMEM:STOR:TRAC:DATA TRACE1, %s", localCSV);
gives me
":MMEM:STOR:TRAC:DATA TRACE1, D:\myFilepath\myFile.csv"
when I want ":MMEM:STOR:TRAC:DATA TRACE1, "D:\myFilepath\myFile.csv""
I tried including an extra set of quotes on the filepath localStorage but I end up with "D:\myFilepath"\"myFile.csv"

 採用された回答

Voss
Voss 2023 年 1 月 10 日
localStorage = 'D:\myFilepath'
localCSV = fullfile(localStorage, 'myFile.csv');
sprintf(":MMEM:STOR:TRAC:DATA TRACE1, ""%s""", localCSV);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

製品

リリース

R2022a

質問済み:

2023 年 1 月 10 日

回答済み:

2023 年 1 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by