How to export script to text file ?

20 Ansichten (letzte 30 Tage)
Arif
Arif am 16 Mär. 2024
Kommentiert: Arif am 16 Mär. 2024
hello please help me to export my code into .txt extension. Is it possible ?
i already tried this code, but it failed

Akzeptierte Antwort

Dyuman Joshi
Dyuman Joshi am 16 Mär. 2024
export() does not support writing data into files.
Use writematrix instead -
a = "good";
b = "morning";
c = "babynumber";
d = 1:10;
%Simplified/vectorized method
str = a + b + c + string(d.')
str = 10×1 string array
"goodmorningbabynumber1" "goodmorningbabynumber2" "goodmorningbabynumber3" "goodmorningbabynumber4" "goodmorningbabynumber5" "goodmorningbabynumber6" "goodmorningbabynumber7" "goodmorningbabynumber8" "goodmorningbabynumber9" "goodmorningbabynumber10"
%write the variable into a txt file
%change the file name as per your liking
writematrix(str, 'Filename.txt')
%checking the contents of the file
type('Filename.txt')
goodmorningbabynumber1 goodmorningbabynumber2 goodmorningbabynumber3 goodmorningbabynumber4 goodmorningbabynumber5 goodmorningbabynumber6 goodmorningbabynumber7 goodmorningbabynumber8 goodmorningbabynumber9 goodmorningbabynumber10

Weitere Antworten (0)

Tags

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by