hexadecimal codes for sine and cosine wave

조회 수: 8 (최근 30일)
sri karthik
sri karthik 2011년 9월 23일
how to plot a sine and cosine wave to obtain a graph which have hexadecimal codes as y axis......or any M-file to find the sine and cosine values in hexadecimal...?
t1 = 0:.1:10; y = sin(t1); plot(t1,y); grid on
i know only this one for generation of sine wave.

답변 (1개)

David Young
David Young 2011년 9월 23일
After making the plot, you can convert the tick labels to the hex representation of the IEEE bit patterns of the numbers with this:
yticks = get(gca, 'YTick');
set(gca, 'YTickLabel', num2hex(yticks));
See
doc axes
doc num2hex
If, however, you want the hex representation of the numbers themselves (i.e. 0.5(dec) becomes 0.8(hex)) then please say so in a comment, and I'll have a think about it.
  댓글 수: 3
Jan
Jan 2011년 9월 26일
I do not get it. What do these numbers mean? If you want to convert decimal numbers to their hex representation, it doe not matter, if they are a sine or random. Usually only integer values are converted to hex strings, but it is possible for frations also. The problem might be clearer. if you describe what you want to achieve.
Walter Roberson
Walter Roberson 2011년 9월 26일
Multiply the sin() or cos() by 256, take int8() of that value, and either use dec2hex() or sprintf() to convert to hex.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by