read.m

来自「对文本文件和音频文件进行OFDM调制和16QAM调制的matlab仿真。」· M 代码 · 共 39 行

M
39
字号
% read

% ******************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
		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);
		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
	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 + =
减小字号Ctrl + -
显示快捷键?