Filter löschen
Filter löschen

How to use "\" in sprintf as a normal character?

33 Ansichten (letzte 30 Tage)
Ahmad Fakih
Ahmad Fakih am 2 Dez. 2019
Beantwortet: Walter Roberson am 2 Dez. 2019
I'm trying to use "sprintf" as follows:
command=sprintf('"C:\Program Files\Computers and Structures\SAP2000 19\SAP2000.EXE" "G:\Desktop\modeling\Sap model thesis\test\Wharf Model %d.0.sdb" /R /C',v);
But I'm getting this warning: Escaped character '\P' is not valid. See 'doc sprintf' for supported special characters.
Although I'm not trying to write any special character (except for %d). How can I use the slash character (\) without considering it a special character and without getting any warning?
Thanks.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 2 Dez. 2019
command = sprintf('%s%d%s', '"C:\Program Files\Computers and Structures\SAP2000 19\SAP2000.EXE" "G:\Desktop\modeling\Sap model thesis\test\Wharf Model ', v, '.0.sdb" /R /C');
or
command = sprintf('"C:\\Program Files\\Computers and Structures\\SAP2000 19\\SAP2000.EXE" "G:\\Desktop\\modeling\\Sap model thesis\\test\\Wharf Model %d.0.sdb" /R /C',v);

Weitere Antworten (0)

Kategorien

Mehr zu Event Functions finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by