达人进来看看?MTLAB实现pcm编码问题

来源:百度知道 编辑:UC知道 时间:2024/06/19 02:36:28
这是一个PCM(脉冲编码调制)在MATLAB中仿真调试的程序
输出时有错~说 ??? Error using ==> fread
Invalid file identifier -1.
其中 fread在第19行~~~
来帮我改正下~~在线等~~对了的加分~~~

% Removing all variables, functions, and MEX-files from memory, leaving the
% workspace empty.
clear all

% Deleting all figures whose handles are not hidden.
close all

% Deleting all figures including those with hidden handles.
close all hidden

% Clearing all input and output from the Command Window display giving us a clean screen.
clc

% Opening the file 'TEOTH.mp3' in the read access mode.
fid = fopen ('TEOTH.mp3','r');

% Generating the input signal 'm(t)' by reading the binary data in 16 bit
% integer format from the specified file and writing it into a matrix
% 'm(t)'.
m = fread (fid,'int16');

% Defining the count for efficiency.
count = 8500;

%

fread函数没有你这样用的方式,主要有以下几种用法:
A = fread(fid)
A = fread(fid, count)
A = fread(fid, count, precision)
A = fread(fid, count, precision, skip)
A = fread(fid, count, precision, skip, machineformat)
[A, count] = fread(...)
你的'uint16' 属于precision,所以你需要加进count(元素的个数)参量。
你试试看行不行