Is it possible to cast the id of a file?

조회 수: 2 (최근 30일)
Javier Naranjo
Javier Naranjo 2017년 12월 12일
편집: Jan 2017년 12월 12일
Hello!
I want to open a file and by default de id is a double type.
I want to cast that value to single for example
f = single(fopen(filename,'r'));
But when I use fread
vector = fread(f,'short');
I get this result
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.
Is there any way to solve this problem? Or is it mandatory to have a double for that variable?
Thanks in advance!
  댓글 수: 1
Rik
Rik 2017년 12월 12일
Why would you want to cast it to single? Apparently it needs to be a double, but why would you want to change it? In future releases it might even be changed to an object, just like was done with handles.

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

채택된 답변

Jan
Jan 2017년 12월 12일
편집: Jan 2017년 12월 12일
No, file handles are expected to be of type double - as you have demonstrated with code.
I cannot imagine, why casting the file handle to another type could be useful. Please explain, which problem you want to solve by this.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by