Al momento, stai seguendo questo contributo
- Vedrai gli aggiornamenti nel tuo feed del contenuto seguito
- Potresti ricevere delle email a seconda delle tue preferenze per le comunicazioni
function result = stresc(string)
returns a string with special characters "escaped"
i.e., the string "Randy's wonton\n % delicious!" becomes
"Randy''s wonton \\n %% delicious!".
Thus, the resulting string is suitable to be printed out and
interpreted by MATLAB. This function is especially useful if you are
writing code intended to produce code. Interpreted strings can be
freely placed into your code without worry of strings breaking code.
The following conversions are made:
% becomes %%
\ becomes \\
' becomes ''
Example Usage:
myString = inputdlg('Please enter a string you want printed',...
'Test StrEsc');
fprintf('%s\n', stresc(myString{1})); % original string, escaped
fprintf('fprintf(''%s'');\n', myString{1}); % won't work for all strings
fprintf('fprintf(''%s'');\n', stresc(myString{1}));
Cita come
Alexander Saites (2026). String Escape (https://it.mathworks.com/matlabcentral/fileexchange/42652-string-escape), MATLAB Central File Exchange. Recuperato .
Informazioni generali
- Versione 1.0.0.0 (1,43 KB)
Compatibilità della release di MATLAB
- Compatibile con qualsiasi release
Compatibilità della piattaforma
- Windows
- macOS
- Linux
| Versione | Pubblicato | Note della release | Action |
|---|---|---|---|
| 1.0.0.0 |
