Clear Filters
Clear Filters

hi all, I am trying to open a file with .001 extension , fopen gives error. can you please help?

4 views (last 30 days)
I am using d=dir(*.001), and can see file name (abcd.001) from name=d.name but fid1=fopen(name) returns negative value.
  4 Comments
James Tursa
James Tursa on 24 May 2017
Edited: James Tursa on 24 May 2017
I assume you meant to type d=dir('*.001') with the single quotes? Works for me PCWIN R2011a:
>> d=dir('*.001')
d =
name: 'abcd.001'
date: '24-May-2017 09:00:35'
bytes: 16
isdir: 0
datenum: 7.3684e+005
>> d.name
ans =
abcd.001
>> fid = fopen(d.name)
fid =
3

Sign in to comment.

Answers (2)

Jan
Jan on 24 May 2017
fopen replies -1, if the name is a folder.
  2 Comments
perveen ali
perveen ali on 24 May 2017
i think there was some issue with folder. I copied file to the same folder where my code is and it works fine now. thanks.

Sign in to comment.


Steven Lord
Steven Lord on 24 May 2017
Call fopen with two outputs. If the first output is -1, display the second output to see why the file open operation did not succeed.

Categories

Find more on Files and Folders 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!