file size determination problem
古いコメントを表示
when I type a code:
size=file.bytes
it shows "Insufficient number of outputs from right hand side of equal sign to satisfy assignment".
回答 (2 件)
Steven Lord
2017 年 1 月 23 日
Your file variable is an empty struct array. Assuming you created it using the dir function, as I suspect is the case, the directory whose contents you tried to list contained no files that matched the file/directory specification.
cd(tempdir)
mkdir directoryWithNoFiles
cd directoryWithNoFiles
file = dir('*.m'); % There aren't any in this newly-created directory
sz = file.bytes % Error
To avoid this, check that your struct variable is not empty using the isempty function before attempting to use the contents.
if isempty(file)
fprintf('The directory contained no files with the .m extension.\n');
else
fprintf('The directory contained %d files with the .m extension.\n', numel(file))
end
Walter Roberson
2017 年 1 月 23 日
size = [file.bytes]
Your "file" is a structure array and you are getting "structure expansion" happening.
カテゴリ
ヘルプ センター および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!