フィルターのクリア

converting to binary (w,t)

4 ビュー (過去 30 日間)
hardik
hardik 2012 年 5 月 9 日
i have this stored as .mat format. when i use plot (t,w) it gives me a graph which kinda looks like a sine graph. I want to convert them to binary format (e.g. 100101010....) and store them as either binary format .bin or as a .txt file. can someone help me out.
they are positive and negative numbers which are relatively very small.
t=[5.97388000000000e-11 1.59738800000000e-10 2.59738800000000e-10 3.59738800000000e-10 4.59738800000000e-10 5.59738800000000e-10 6.59738800000000e-10 7.59738800000000e-10 8.59738800000000e-10 9.59738800000000e-10]
w= [0.000200000000000000 0.000120000000000000 -4.00000000000000e-05 -0.000120000000000000 0.000280000000000000 0.000520000000000000 0.000440000000000000 0.000440000000000000 0.000520000000000000 0.000600000000000000]
please give me comments on ur code. and also give me as examples so that it is easy for me to follow. thank you so much guys! matlab forum is so good.
  1 件のコメント
hardik
hardik 2012 年 5 月 9 日
this is just 10 data points. i have 1,000 data points for both t and w.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 5 月 9 日
As I wrote in your earlier question,
Strings of '0' and '1' as produced by dec2bin() is not called "binary" in traditional computer programming. "binary" in traditional computer programming always refers to a numeric format, not to a string format.
Let us take one of your data points, 0.000200000000000000 : exactly what do you want emitted for that? Be sure to distinguish between bytes that are numerically 0 or numerically 1, and bits that are numerically 0 or numerically 1, and characters that are '0' or '1' (which are bytes whose numeric values are 48 or 49.)
  2 件のコメント
hardik
hardik 2012 年 5 月 9 日
ok. lets say to save this .mat data to .txt format i have used
save('data.txt', 't', 'w' , '-ascii')
now how do i save this same information as a sting of 1 and 0 in the .txt format.
i just don't want numbers in the .txt file. i need them as (.....001010110......)
hardik
hardik 2012 年 5 月 9 日
converting w i can simply use dec2bin(t,8) but what about t?? how can i convert that small positive and negative numbers? and then store both of them in the same .txt file?

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by