How to validate,the two text files using one validate function after uploaded the files to matlab GUI ?? Hereby I have attached the screenshot also!!!
Show older comments
Hello, Kindly help me to solve this issue, the validate function ,it should say weather both the file is uploaded properly,if any one file is not uploaded,it should give an error message,if both file is uploaded correctly,then function should display that your file is uploaded.
9 Comments
Rik
on 17 Dec 2017
Although some people have been working with Matlab for so long that they can work wonders with it, mind reading is not yet one of the things contributors can do. You need to provide details about what it is you are doing, what it is you want and what is going wrong.
Jan
on 17 Dec 2017
@sonu: I agree with Rik. As long as you do not explain what "validating" means, how could anybody suggest anything? Please edit the question and insert much more details.
sonu
on 17 Dec 2017
Rik
on 17 Dec 2017
What would being uploaded mean? That a file is selected and it exists? Try to make your question as much a pure Matlab question as you can, because that is where we will be most likely to be able to help.
sonu
on 18 Dec 2017
Edited: Walter Roberson
on 18 Dec 2017
Walter Roberson
on 18 Dec 2017
if exist(fullpathname, 'file')
%at the very least the file exists
%checking to see whether the file _content_ is acceptable
%is usually as difficult as actually reading the file
%and collecting the data from it
end
Jan
on 18 Dec 2017
@sonu: You are talking of "both files", but I see one file only. Then please mention, what "uploaded properly" exactly mean. How can you check this? Maybe "both" files are existing, but different.
sonu
on 19 Dec 2017
Edited: Walter Roberson
on 19 Dec 2017
Walter Roberson
on 19 Dec 2017
After you have given the message in the case the user selects cancel, you should return from the function.
fid1 =fopen(fullpathname1,'r','ieee-be','US-ASCII');
fid1 = fopen(fullpathname1)
Why are you doing the fopen twice?
if isempty(fid1)
fopen() never returns empty. fopen always returns an integer that is positive if the file could be opened. You cannot tell whether a file is empty by looking at the file identifier returned by fopen.
You could dir() the file and look at the bytes field to determine whether it is completely empty. It is probably not a useful test to do at that point.
text = fileread('fullpathname')
That attempts to read the content of a file literally named fullpathname . If you want to read the content of a file whose name is in the variable fullpathname then use
text = fileread(fullpathname)
Then you have
a = appleconfig.txt,nokiadata.txt
That attempts to find a structure or class named appleconfig and find its method or field name named txt .
If you were to correct that to
a = 'appleconfig.txt,nokiadata.txt'
then your next line
if strcmp(a,filename1)==1
is quite unlikely to match, as it is quite unlikely that the user happened to select a file literally named appleconfig.txt,nokiadata.txt
Perhaps you want:
a = {'appleconfig.txt', 'nokiadata.txt'}
if ismember(filename1, a)
Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!