Open a .txt file scripting
Hello,
I'm trying to open a .txt file in Compose but I get an error.
Error: invalid input in argument 1; type must be a string or a valid file stream in call to function textscan at line number 2
fid = fopen('nodes.txt');
track =textscan(fid, '%f %f %f %f %s %s');
fclose(fid);
track_node = track{:,1};
x_node_track = track{:,2};
y_node_track = track{:,3};
z_node_track = track{:,4};
Do I need to import the txt file firstly ? If yes how can I do it?
How can I call a .txt file in Compose?
Thank you!
Find more posts tagged with
Do you see 'fid' variable has a negative value ? if so, you might not have the 'nodes.txt' in the current working directory. can you please make sure you have the file in current working directory, if not change the working directory or have the fullpath to the file.
like:
fid =fopen('C:/temp/test.txt', 'r')
thanks,
Manoj kandukuri
Do you see 'fid' variable has a negative value ? if so, you might not have the 'nodes.txt' in the current working directory. can you please make sure you have the file in current working directory, if not change the working directory or have the fullpath to the file.
like:
fid =fopen('C:/temp/test.txt', 'r')
Thank you very much Manoj.
I worked that way.
Hello,
Could you please share you text file 'nodes.txt'?
Using fopen command is enough to import the file, apparently there is a problem with your text file. That is why it would be good if you could share it here.
Regards,
Roberta