Error using fread Invalid file identifier. Use fopen to generate a valid file identifier.

조회 수: 13 (최근 30일)
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

채택된 답변

Stephen23
Stephen23 2020년 6월 5일
편집: Stephen23 2020년 6월 5일
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.
  댓글 수: 1
Jordan Stocker
Jordan Stocker 2020년 6월 5일
Thanks that works great now
but the strip lines which are meant to remove the letters so that the data can go through the calculations dont work either any sugestions would help lots

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

N___e
N___e 2020년 6월 5일
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.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by