📄 read.m
字号:
% read
%input_type==2
%file_input_type==3
% ******************FILE INPUT SETUP*********************************
if input_type == 2
if file_input_type == 1
%binary file input
end
if file_input_type == 2
%text file input
file = fopen(file_name,'rt');
data_samples = fread(file,'char');
fclose(file);
data_in = zeros(1,8*length(data_samples));
for i = 1:length(data_samples)
data_in(1 + (i-1)*8:(i-1)*8 + 8) = eight2bin(data_samples(i));
end
end
%**********************************************************************
%*****************
if file_input_type == 3
%sound file input
file_name;
data_samples=wavread(file_name);
%needs to be normalized from -1:1 to 0:255 for 8 bit conversion
data_samples_resized = round(128*data_samples +127);
length(data_samples_resized);
data_in = zeros(1,8*length(data_samples_resized));
for i = 1:length(data_samples_resized)
data_in(1 + (i-1)*8:(i-1)*8 + 8) = eight2bin(data_samples_resized(i));
end
data_in;
end
if file_input_type == 4
%image file input
[data_in,map]=imread(file_name); % read image and corresponding color map for display
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -