Creating an array of different data types (integer and float)
7 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 19 Feb 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
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!