Typecasting a matrix of 200x8 uint8 to double
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
vishwajit jadhav
el 18 de Sept. de 2018
Comentada: Christopher Wallace
el 18 de Sept. de 2018
I am typecasting data from uint8 to double so I am using typecast function. I have matrix of 200x8 uint8 which want to convert it into double. So if I use a for loop like below.
if true
convert_double = [];
a = [200x8];
for i =1:200
convert_double = [convert_double; typecast(uint8(a(i,:)), 'double')];
end
end
But I want to remove this for loop so that in one instance itself I will get 200x1 double data
0 comentarios
Respuestas (2)
Guillaume
el 18 de Sept. de 2018
Transpose your a before reshaping into a vector:
convert_double = typecast(reshape(uint8(a'), 1, []), 'double')
0 comentarios
Christopher Wallace
el 18 de Sept. de 2018
double(a);
2 comentarios
Christopher Wallace
el 18 de Sept. de 2018
Absolutely, depends on what the author wants to do with the data. After seeing your answer I see what the "200x1 double data" portion was aiming at.
Ver también
Categorías
Más información sobre Numeric Types en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!