Borrar filtros
Borrar filtros

Problem When Concatenating 2 Arrays [Help]

2 visualizaciones (últimos 30 días)
ElevenFourth
ElevenFourth el 8 de Abr. de 2013
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

Respuesta aceptada

Roger Stafford
Roger Stafford el 9 de Abr. de 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.
  1 comentario
ElevenFourth
ElevenFourth el 9 de Abr. de 2013
Thank you very much for your answer Mr. Stafford. I just have to adjust the format, and actually nothing happens with the calculation.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by