Numeric array values replaced with zeros
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jrb13
am 18 Sep. 2017
Bearbeitet: James Tursa
am 18 Sep. 2017
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.
0 Kommentare
Akzeptierte Antwort
James Tursa
am 18 Sep. 2017
Bearbeitet: James Tursa
am 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!