1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

New to MatLab: Having some trouble

  1. Oct 10, 2014 #1
    1. The problem statement, all variables and given/known data

    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?


    2. Relevant equations
    N/A

    3. The attempt at a solution

    My attempt is shown above
     
  2. jcsd
  3. Oct 10, 2014 #2
    Nevermind, sorry.. Apparently I forgot to type ".txt" at the end..
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: New to MatLab: Having some trouble
Loading...