How to convert single cell value into an array?

I have a double value of -35.14 saved as a vector of 8 elements uint8 type like this:
array = [90 62 162 85 148 146 65 192]
I can convert the vector into single-cell value using command:
J1=typecast(conf(1:8), 'double');
The result is single-cell value of -35.14, so the operation is correct. The problem occurs when I want to perform an inverse operation, which is to convert the value of -35.14 back into an array of 8 elements. The inverse operation seems to be command:
cast(J1, 'uint8')
Although it doesn't work at all the way I want it. I converts it only to another single-cell value of different type e.g. uint8 instead of 8-elements array.

4 件のコメント

John BG
John BG 2016 年 4 月 17 日
define conf
typecast(conf(1:8), 'double');
Undefined function or variable 'conf'.
Mikolaj Olszanski
Mikolaj Olszanski 2016 年 4 月 17 日
well, as I said it's this array:
array = [90 62 162 85 148 146 65 192]
if it makes any differency to you the command might be as well:
J1=typecast(array, 'double');
Image Analyst
Image Analyst 2016 年 4 月 17 日
Of course it makes a difference. In computer programming even one character can make all the difference in the world. I immediately thought of the same thing John did.
Mikolaj Olszanski
Mikolaj Olszanski 2016 年 4 月 17 日
okay, sorry if I didn't make it clear in the first place. thanks for your interest though.

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2016 年 4 月 17 日

0 投票

Not
cast(J1, 'uint8')
but
typecast(J1, 'uint8')

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by