Effacer les filtres
Effacer les filtres

Problem with file text size in bytes

1 vue (au cours des 30 derniers jours)
wissa amer
wissa amer le 30 Juin 2013
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 commentaires
wissa amer
wissa amer le 30 Juin 2013
I Mean in bytes .
Jan
Jan le 1 Juil 2013
@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!

Connectez-vous pour commenter.

Réponses (1)

Chandrasekhar
Chandrasekhar le 30 Juin 2013
Modifié(e) : Chandrasekhar le 30 Juin 2013
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 commentaires
Walter Roberson
Walter Roberson le 1 Juil 2013
What happens when you try to do it in your GUI?
Jan
Jan le 1 Juil 2013
Explicitly:
dirList = dir(fullfile(pathName, fileName));
fileSize = dirList.bytes;

Connectez-vous pour commenter.

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by