Creating an array of different data types (integer and float)
조회 수: 7 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2013년 2월 19일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!