save as .txt file from .jpg directories

3 views (last 30 days)
Tulips
Tulips on 6 Jul 2012
hi sir, can I know why it cannot save as text file? here is the script
files = dir('*.jpg');
for k = 1:numel(files)
input_name = files(k).name;
[path, name, extension] = fileparts(input_name);
output_name = fullfile(path, [name '.txt']);
save(files(k).name,'-ASCII')
end
it gives warning:
Warning: Attempt to write an unsupported data type to an ASCII file.
Variable 'structuringElement' not written to file.
Warning: Attempt to write an unsupported data type to an ASCII file.
Variable 'subImage' not written to file.
[EDITED, Jan, code and warnings formatted] Please do this by your own in the future - thanks!

Answers (1)

Jan
Jan on 6 Jul 2012
The command save writes all variables of the current workspace to disk, if the variables are not specified. When the ASCII format is used, only a subset of the possible types is possible. E.g. how should a nested struct, which contains cell arrays, whose elements are UINT16 arrays, be written unequivocally in ASCII format?!
Either use the binary format -MAT, or specify the variables, which are written and which have the apropriate type. Read doc save for more details.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!