how to add a column as input for hexadecimal to decimal/binary conversion
2 ビュー (過去 30 日間)
古いコメントを表示
Padmamalini T H
2020 年 1 月 12 日
コメント済み: Padmamalini T H
2020 年 1 月 20 日
i have a table of ascii codes which i need to convert them to decimal or binary format to decode it. but im not able to give the columns of the table as input for conversion. is there a way to do so?
i have used the following code:
B = T(T.message=='18FF0803x',:);
columns = B(:,3:end);
first_column1 = columns(:,1);
first_column1 = hex2dec(first_column1);
And, im getting the following error-
Error using hex2dec (line 30)
Input to hex2dec must be a character vector, string, or cell array of character vectors.
2 件のコメント
Adam Danz
2020 年 1 月 12 日
編集済み: Adam Danz
2020 年 1 月 12 日
It's clear that the message column contains hexidecimal char arrays or strings but we have no idea what's in the 3rd column of your table (the column causing the error). We do know that whatever is in that column, it's not a char vector, string or cell array of char vectors.
Could you show us the result of
head(T)
Also, the correct way to identify string matches is by using strcmp()
B = T(strcmp(T.message,'18FF0803x'),:);
dpb
2020 年 1 月 12 日
We can't tell what B contains because we don't have T or even an example of it.
We don't know for sure B isn't empty, even...
Attach a sample part of the data...
Whatever B is, the message is telling you the third column isn't a valid hex string representation that hex2dec can work on.
採用された回答
Walter Roberson
2020 年 1 月 12 日
B = T(T.message=='18FF0803x',:);
T is a table() object, so extracting some rows of it gives a table object.
columns = B(:,3:end);
Extracting columns from a table object give a table object.
first_column1 = columns(:,1);
Extracting one column for a table object gives a table object.
first_column1 = hex2dec(first_column1);
hex2dec cannot process table objects.
first_column1 = columns{:,1};
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Report Generator についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!