save as .txt file from .jpg directories

3 次查看(过去 30 天)
Tulips
Tulips 2012-7-6
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!

回答(1 个)

Jan
Jan 2012-7-6
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.

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by