Problem When Concatenating 2 Arrays [Help]
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear Friends,
I am facing a problem when concatenating 2 arrays. Let's say that I have variable A, which is a 500x2 double (filled by integers), and variable B which is a 500x1 double (filled by real numbers).
A =
23 12
25 10
7 30
B =
0.18237
0.23872
0.45657
If I use :
C = horzcat(A, B);
or
C = [A B];
Matlab would show a result such as :
.
0.0000 0.0000 0.1635
0.0000 0.0000 0.5378
0.0000 0.0000 0.1029
0.0000 0.0000 0.1207
The first two column would be zero.
Anyone have an idea why this is happening?
Thanks in advance
0 Kommentare
Akzeptierte Antwort
Roger Stafford
am 9 Apr. 2013
The problem is not in the concatention; it is in the display of the results. Apparently all the entries from A that are shown are smaller in magnitude than 0.00005 so that when rounded to four places you see a zero displayed. Try using "format long" before displaying the results. Or better still use floating point formatting provided by fprintf to allow each entry to be displayed in accordance with its own magnitude. Your first row might then look something like this:
1.111111111111111e-10 -2.222222222222222e-11 1.634987654321234e-1
Note: I am responding here to your original posting. As you have now edited it the results look impossible. You had better check that again.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!