필터 지우기
필터 지우기

error using open, too many input arguments. error in fopen

조회 수: 4 (최근 30일)
Pree
Pree 2015년 8월 24일
답변: Hussain Baloch 2018년 12월 7일
I have a m.file which looks something like this.
for p = 1:2
if p==1
[data,txt,raw]=xlsread('subject_1.xlsx');%%this is reading file of subject 1
fid4=fopen('new_1_datafile.dat','w');
end
if p==2
[data,txt,raw]=xlsread('subject_2.xlsx'); %%%%%%reading file of subject 2
fid4=fopen('new_2_datafile.dat','w')'
end
...
...
%%%written fid1,fid2,fid3 datafiles
...
...
...
%%%there are lots of lines where i calculate different things for each subjects (there are 72 different %%%subjects but for simplicity i am just trying with 2).
fprint(fid4,.......) %%%printing out some important data
fclose(fid1)
fclose(fid2)
fclose(fid3)
fclose(fid4)
end
how can i make sure the fid4 file for the first subject is cleared before writing fid4 file for the second subject? With the above code, I am getting an error message which says, 'error using open, too many input arguments'. The error shows in line 8 when opening fid4 for second subject. So I think it is because I am opening the same file again for the second subject which has been already written for the first subject. But I have allocated different datafile name for the fid4 files for the 2 subjects. Why am I getting this error?

채택된 답변

dpb
dpb 2015년 8월 25일
"error using open, too many input arguments'." clearly is bogus as an error message for fopen.
Note above it says "open" not "fopen" which means likely means there's actually a call to function open which indeed does only accept a single argument and the actual line you executed wasn't the one in the code above but something like--
fid4=open('new_2_datafile.dat','w');
NB. also above you've got a conjugate transpose operator at the end of the statement instead of a semicolon--that won't hurt anything from an operational standpoint; just echo the value and return the complex conjugate of a positive integer which is the same as the integer. I don't know what that might do in lastest releases wherein a file handle is an object instead of just a double...
Anyway, make sure you really have fopen everywhere and try again...if it fails again, post the whole error in context with the calling routine, but I'll bet you've got a typo in the m-file you executed.
  댓글 수: 2
Pree
Pree 2015년 8월 25일
thank you. I put open only on one of the lines instead of fopen.
Walter Roberson
Walter Roberson 2015년 8월 25일
It helps when you post the actual code, especially the code at the line that is creating the error, together with the complete error message.

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

추가 답변 (1개)

Hussain Baloch
Hussain Baloch 2018년 12월 7일
open system ('PV50')
nvals = 0;
figure
for gval=0.2:0.2:1
nvals=navals+1;
gvalsStr-num2Str(oval,3);
set_param('PV50/G1','Gain',gvalStr);
sim('PV50');
plot(v,i);
hold on
end
hold off
this is not working pls help urgently

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by