Numeric array values replaced with zeros

12 views (last 30 days)
I am using the Import Data icon in the Home toolbar to import data from .csv files. I am able to import only the columns I want as a numeric matrix and exclude any rows with unimportable data. When I call these variables in the command window, all the values in every row are replaced with zeros, except for a column of ones. If I click the variable in the workspace, the matrix has the correct values. Do you have any advice as to where I am going wrong or what might be happening? I have uploaded a screenshot of the issue with the variable highlighted in the workspace, the correct matrix values showing in the Variables, and the matrix of zeros and ones that results when I type the variable (WT3speed) and enter into the command window. I have also uploaded the .mat file of the variable, WT4speed. This is not unique to this variable. It has been happening when I import other data of this type.

Accepted Answer

James Tursa
James Tursa on 18 Sep 2017
Edited: James Tursa on 18 Sep 2017
This is just a display issue. The values are still there. E.g.,
>> x = [-3 10 1e9 4 300]
x =
1.0e+009 *
-0.0000 0.0000 1.0000 0.0000 0.0000
>> x(1)
ans =
-3
>> x(2)
ans =
10
>> x(3)
ans =
1.0000e+009
>> x(4)
ans =
4
>> x(5)
ans =
300
See that "1.0e+009 *" at the top? That is a multiplier for all of the numbers in the display of that variable. The numbers show up as 0.0000 simply because of the wide range in the values, but the numbers are really there intact. You could use a different display format to reveal this:
>> format longg
>> x = [-3 10 1e9 4 300]
x =
Columns 1 through 4
-3 10 1000000000 4
Column 5
300
If the numbers are exactly 0 they will show up without any trailing decimal digits. E.g.,
>> format short
>> x = [0 0 1e9 0 0]
x =
1.0e+009 *
0 0 1.0000 0 0
  1 Comment
jrb13
jrb13 on 18 Sep 2017
Thank you! No, I couldn't see the 1.0e+009 at the top, because my arrays are large enough that when I call them, I can't scroll all the way up! It only displays so much, which I haven't quite found a solution to yet either. I now see that I can still use the variables in functions and it computes as the actual values, not the displayed values.

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!