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

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

 Respuesta aceptada

Stephen23
Stephen23 el 5 de Jun. de 2020
Editada: Stephen23 el 5 de Jun. de 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.

1 comentario

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

Iniciar sesión para comentar.

Más respuestas (1)

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.

Categorías

Más información sobre Large Files and Big Data en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 5 de Jun. de 2020

Respondida:

el 5 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by