Problem with file text size in bytes

in GUI MATLAB HOW I CAN FIND THE SIZE OF THE FILE TEXT AFTER IMPORT THIS FILE BY THIS CODE :
[file,path] = uigetfile('*.txt','Select file');
var=strcat(file,path);
file=dlmread(var);
------------------------------
and i used this code to read the file text
[filename,pathname] = uiputfile( ...
{'*.txt','save as'});
var=strcat(pathname,filename);
dlmwrite(var,x);

3 件のコメント

Chandrasekhar
Chandrasekhar 2013 年 6 月 30 日
hi, what do u mean by size. size of the file in bytes or size of the filename?
wissa amer
wissa amer 2013 年 6 月 30 日
I Mean in bytes .
Jan
Jan 2013 年 7 月 1 日
@wissa amer: It is recommended to avoid using "path" as name of a variable, because this is an important Matlab command. Such a shadowing can cause serious troubles during debugging. The same concerns to "var", which calculates the variance.
Instead of var=strcat(file,path) the function fullfile is safer:
[fileName, pathName] = uigetfile('*.txt','Select file');
file = fullFile(pathName, fileName); % Swapped arguments!

サインインしてコメントする。

回答 (1 件)

Chandrasekhar
Chandrasekhar 2013 年 6 月 30 日
編集済み: Chandrasekhar 2013 年 6 月 30 日

0 投票

use the command
a= dir('complete path of the file')
example: F:\Matlab\text.txt
It gives a structure with bytes as one of the field

4 件のコメント

wissa amer
wissa amer 2013 年 6 月 30 日
i can not do this in my GUI
Chandrasekhar
Chandrasekhar 2013 年 7 月 1 日
Could you plz tell me how your GUI looks like and what are u trying to do frm your GUI
Walter Roberson
Walter Roberson 2013 年 7 月 1 日
What happens when you try to do it in your GUI?
Jan
Jan 2013 年 7 月 1 日
Explicitly:
dirList = dir(fullfile(pathName, fileName));
fileSize = dirList.bytes;

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeVariables についてさらに検索

タグ

質問済み:

2013 年 6 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by