image thumbnail

EXPO 2011 Signal Processing Workflow Demo Files

by

 

MATLAB EXPO 2011 Signal Processing Workflow Demo Files

readwrite_hex.m
%% HEXt@CRead/Write
close all, clear all

%% M̍쐬
t = ([0:99]/1000);
signal1 = round((2^15-1)*sin(2*pi*30*t))';
plot(t,signal1,'b*-')

%% Œ菬_f[^̊mF
signal1_fxpt=fi(signal1,1,16,0);
signal1_fxpt.hex
hold on, plot(t,signal1_fxpt,'bo-')

%% t@CWrite
fid = fopen('hex_data1.txt','w');
% tHEXf[^
% fprintf(fid,'%+04x\n',signal1+ (signal1<0) * 2^16);	% format: ffff
% fprintf(fid,'16''h%+04x\n',signal1+ (signal1<0) * 2^16);	% format: 16h'ffff
fprintf(fid,'0x%04x\n',signal1+ (signal1<0) * 2^16);	% format: 0xffff
fclose(fid);

% \[Vy[W
% http://siebel.mathworks.com/Solutions/Prod/Sol_1-15K23/SolDetail/SolDetail.htm

%% t@CI[vēemF
edit hex_data1.txt

%% t@CRead
fid = fopen('hex_data1.txt','r');
signal1_file = fscanf(fid,'%x\n');
% sig_file = fscanf(fid,'%i');	% 0x%x\nł
fclose(fid);

signal1_file = signal1_file-(signal1_file > 2^15-1)*2^16;	% 7fffȂ-2^16ItZbg
% figure,plot(t,signal1_file,'ro-')
hold on, plot(t,signal1_file,'ro-')

%%
% diffSvf0Ȃ1o
signal_diff = all((signal1_file-signal1)==0)	

Contact us