answerstu

MATLAB - Load data file with a string file name

I am writing a Matlab program that loads a data file created in another C++ program. planet = input('What is the name of your planet? ', 's') data_file = strcat(planet, '.dat') load(data_file); data_file; x = data_file(:,1); y = data_file(:,2); plot (x,y,'r*')The program takes the name of the planet as the user input, then concatenates ".dat" to the end of the planet name. This gives, for example, "earth.dat," which is the name of the file created by the other C++ program.I have made sure that the data file being loaded is...Read more

load() - ignoring a given string

I am trying to use the load() function in MATLAB to read in data from a text file. However, every line of the text file ends with '...'. The data file is not produced by MATLAB, so I have no control over the source of the ellipses.The data file I'm loading in looks something like this:11191425 NaN NaN 0.0 ...11191426 NaN NaN 0.0 ...11191427 NaN NaN 0.0 ...11191428 NaN NaN 0.0 ...11191429 2280.5 1910.1 455.0 ...11191430 2280.5 1910.1 455.0 ...11191431 2298.0 1891.1 ...Read more