Creating an array of different data types (integer and float)

8 visualizaciones (últimos 30 días)
Matthew Burrows
Matthew Burrows el 19 de Feb. de 2013
Hi,
I want to combine two vertical 1D arrays, one of which is a list of numbers from 1 to 10, the other is a list of other numbers which are all decimals. For reference, my variables are n and results and the combined array is A
When I combine them, the integers n into floats (I think that's what they're called) 1.0000, 2.0000 ...etc. I want these to be integers so I try putting A = [int8(n),results]; this changes n to integers but also changes results to integers, which are all zero (I guess it's rounding them down- they are all less than 1).
I've also tried A = {[int8(n),results]}, but this comes up as A = [10x2 int8] in the command window.
Thanks

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de Feb. de 2013
It is not possible to have a numeric array that has a mix of datatypes.
Please give the command
format long g
and then re-display (part of) the vertical concatenation to see whether the ".0000" still shows up

Categorías

Más información sobre Logical 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