Matlab table with 2 different type numbers
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
buer
el 20 de En. de 2015
Comentada: buer
el 21 de En. de 2015
Hello all,
I want to put those two types of number inside one table. One column with index int64 and another column with value single....
1359410513
1359410521
1359410529
1359410536
1359410542
1359410548
1359410554
40.299999
39.099998
37.900002
36.799999
35.700001
34.700001
33.599998
But when I put them in one the value says is: 2000 X 2 int64. SO all the values are cut away after dot. like this:
40
39
38
37
36
35
34
can anyone help me with this? how to put them in one table. Thanks
0 comentarios
Respuesta aceptada
John D'Errico
el 20 de En. de 2015
This is because MATLAB does not allow traditional matrices with various types in each row or column. So it will convert the type of one column to match the other.
So you cannot do what you wish, UNLESS you use a cell array, where you can combine anything.
3 comentarios
John D'Errico
el 21 de En. de 2015
Editada: John D'Errico
el 21 de En. de 2015
There are several ways for that not to be a problem, so I don't think you do understand what I mean.
C = {uint64(1:100), rand(1,100)};
So now C{1} is a uint64 vector. C{2} is a real vector. Do any computations on them that you wish. WTP?
C{1}(2)
ans =
2
class(C{1}(1))
ans =
uint64
C{2}(2)
ans =
0.905791937075619
Or, you can create a 100x2 cell array, where the elements in the first column are all uint64, and the elements in the second column are all real numbers. NOTHING says that in order to do any operations on these numbers, that you need to convert the ENTIRE array to a flat array, does it? Are you telling me that you cannot first extract the first column of elements, and THEN convert that vector to a regular array?
My first suggestion is simpler to deal with of course, so that is what I'd do, but are you honestly telling me that it cannot be done with a cell array? I'll concede only that it is not as easy to directly access these numbers, since you then need to work with a cell array. You are the one who feels the need to combine them though, not me.
Más respuestas (0)
Ver también
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!