Effacer les filtres
Effacer les filtres

converting to binary (w,t)

4 vues (au cours des 30 derniers jours)
hardik
hardik le 9 Mai 2012
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 commentaire
hardik
hardik le 9 Mai 2012
this is just 10 data points. i have 1,000 data points for both t and w.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 9 Mai 2012
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 commentaires
hardik
hardik le 9 Mai 2012
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 le 9 Mai 2012
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?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by