Error using fread Invalid file identifier. Use fopen to generate a valid file identifier.
13 views (last 30 days)
Show older comments
hi im trying to create this code for one of my assesments and for some reason it kkeeps coming up with this message im pretty sure everything else is correct btu i cant find whats causing the errror mesage above.
my code and one of the files its meant to read from is included
0 Comments
Accepted Answer
Stephen23
on 5 Jun 2020
Edited: Stephen23
on 5 Jun 2020
The problem is that your code only uses the filename, but you need to also provide the filepath (otherwise how does MATLAB know where the file is saved?). The filepath is provided as the second output of uigetfile:
[F,P] = uigetfile();
Results1 = fullfile(P,F);
Important: you should fclose every file that you fopen, otherwise your code will just collect more and more handles to open files, which can eventually cause various problems (errors, unresponsive, etc.)
Tip: you should name your variable with something more descriptive, i.e. that actually reflects their content and type.
More Answers (1)
N___e
on 5 Jun 2020
Strip command only strip a single character.
stripCharacter — Character to strip from input text
' ' (default) | character | string
Character to strip from input text, specified as a character or as a string that contains one character.
You can use the erase command,
It can match the string you want to erase.
0 Comments
See Also
Categories
Find more on Dates and Time 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!