how to convert char data to Double?

I have a data like
0.104895105
0.112244898
0.139534884
I converted it to binary but it becomes a char data after conversion . how can i convert back to double so that nnstart can take it as input.
kindly help me with it . tx

7 件のコメント

James Tursa
James Tursa 2015 年 10 月 19 日
How did you convert it to binary? Please show the MATLAB code you used to do this.
Walter Roberson
Walter Roberson 2015 年 10 月 19 日
Amit Mishra
Amit Mishra 2015 年 10 月 19 日
@james I used MyNum2Bin(A,4,0,1)
Amit Mishra
Amit Mishra 2015 年 10 月 19 日
@walter sorry its nnstart
Walter Roberson
Walter Roberson 2015 年 10 月 20 日
We have no idea what the code is for MyNum2Bin
Amit Mishra
Amit Mishra 2015 年 10 月 20 日
編集済み: Walter Roberson 2015 年 10 月 20 日
@walter Good Morning. Sorry for the delay. here is the code you requested.
function [y]=MyNum2Bin(x,NumOfBit, Min,Max)
P= ((x - Min) *(2^NumOfBit-1))/(Max-Min)
% if P >1
% y =dec2bin(P,NumOfBit)
% else
% X=abs(P)
% y=dec2bin(X,NumOfBit)
% end
% if P >1
y =dec2bin(abs(P),NumOfBit)
% else
% X=abs(P)
% y=dec2bin(X,NumOfBit)
% end
Amit Mishra
Amit Mishra 2015 年 10 月 20 日
In this case i dont have any -ve value. So hope i should not be worried. Anyway tx for the point out the error. Please can you give me a code which can 1. if i have 3 column of data 2. convert the data to binary 3. concat it to one data 4. transpose the concated data 5. and take it as input. Thanks

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

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 20 日

0 投票

t = MyNum2Bin(A,4,0,1); %your existing call
u = t - '0'; %now it is 0 and 1's
Note: your MyNum2Bin code treats negative values as positive values.

2 件のコメント

Amit Mishra
Amit Mishra 2015 年 10 月 20 日
編集済み: Walter Roberson 2015 年 10 月 20 日
In this case i dont have any -ve value. So hope i should not be worried.
Anyway tx for the point out the error.
Please can you give me a code which can
  1. if i have 3 column of data
  2. convert the data to binary
  3. concat it to one data
  4. transpose the concated data
  5. and take it as input.
Thanks
Walter Roberson
Walter Roberson 2015 年 10 月 20 日
Avec = reshape( (dec2bin(floor(A*16), 4) - '0').', 1, []);
"Take it as input" is too vague. Take it as input to what? And what format does the input require?

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

カテゴリ

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

製品

質問済み:

2015 年 10 月 19 日

コメント済み:

2015 年 10 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by