Reading in array from txt file

I'm trying to read in a txt file but MATLAB is only reading in the last column and showing zeros where the other data should be? I checked the txt file and the data is there, and all the values are separated by spaces. Any idea why the first columns are being read in as zeros? My code looks like this:
load ScenarioA.txt; load ScenarioB.txt; ScenarioA

 Accepted Answer

Your format setting could be the problem. See if setting
format short g
in your script solves the problem.
Example
format short
x = [1E-10 10]
format short g
x = [1E-10 10]
x =
0.0000 10.0000
x =
1e-10 10

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!