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

7 vues (au cours des 30 derniers jours)
Matthew Burrows
Matthew Burrows le 19 Fév 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

Réponses (1)

Walter Roberson
Walter Roberson le 19 Fév 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

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by