New to MatLab: Having some trouble

  • Thread starter Thread starter Yosty22
  • Start date Start date
  • Tags Tags
    Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 1K views
Yosty22
Messages
182
Reaction score
4

Homework Statement



This isn't really for homework, but I wasn't sure where else to put it. anyone wishes to move it, that is fine. I'm just getting into some research and I was tasked with reading data from a text file into MatLab and then graphing it by fitting it with exponentials. I am very new to MatLab, so I am just trying to read the data in as of right now, and I'm not sure what's going wrong. I have used many sources online and I have done almost exactly what they said.

My code right now is as follows:

filename = 'aucdstio2_long_ave_combined';
fileID = fopen(filename,'r');
temp = textscan(fileID, '%s%s');

I am using the part '%s%s' because the file is formatted as:
-1.0000000e+003 1.5354302e+002

This is an example of the first line, but there are around 500 lines that are all identical to this. I figured due to the "e+003" it would be better to read it in as a string. However, when I try to run it, I keep getting the error: "

Error using textscan
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in Data_ReadIn_aucdstio2_long_ave_combined (line 5)
temp = textscan(fileID, '%s%s');

It is weird to me, because this is exactly what various sites I have found have said.

Any ideas what's going on here?

Homework Equations


N/A

The Attempt at a Solution



My attempt is shown above
 
Physics news on Phys.org
Nevermind, sorry.. Apparently I forgot to type ".txt" at the end..