MATLAB Answers


how to use fopen in this situation?

Hi I have created a Function like the following function, the function acceopts a Text file name as input. I want to open this text file with fopen, but it seems it is not possible. what can I do? here is the function:
function myfunction =rob2xml
dlg_title='Joint values;
def= {'test1.txt',};
ts = inputdlg(prompt,dlg_title,num_lines,def);
%Now when i write ts in matlab command line I have %ts='test1.txt'
RP=textscan(fid,'%*s %*s %s %*s %*s %s','delimiter',',');
but it seems that fopen does not work in this way and i should write the name of file in string format, but because i have to change the input file, what shall i do? and i have this message: ??? Error using ==> textscan First input can not be empty. Error in ==> testmeisam at 20 RP=textscan(fid,'%*s %*s %s %*s %*s %s','delimiter',',');

  댓글 수: 1

How do you format your text file?

로그인 to comment.


답변 수: 1

 채택된 답변

ts is cell array.
please try
ts = cell2mat(ts);
after line
ts = inputdlg(prompt,dlg_title,num_lines,def);

  댓글 수: 1

thans alot, it works now

로그인 to comment.

Translated by