Error using reshape To RESHAPE the number of elements must not change.

1 visualización (últimos 30 días)
thva1011 Than
thva1011 Than el 23 de Abr. de 2018
Editada: dpb el 23 de Abr. de 2018
Please help me with this Matlab code error
fileTx = 'Plosives.wav';
[fData,Fs] = audioread(fileTx);
orig_size = size(fData);
binData = dec2bin(typecast(single(fData(:)),'uint8'),8);
txAudio = reshape((binData-'0').',1,[]).'; % Create binary stream
str = reshape(sprintf('%d',rxData(1:length(txAudio))),8,[]).';
decdata = uint8(bin2dec(str));
rxAudio = reshape(decdata,orig_size);
% Play received audio
sound (rxAudio,Fs);
  4 comentarios
thva1011 Than
thva1011 Than el 23 de Abr. de 2018
Editada: thva1011 Than el 23 de Abr. de 2018
Hi, I am following this link https://www.mathworks.com/help/supportpkg/xilinxzynqbasedradio/examples/transmit-and-receive-802-11a-using-analog-devices-ad9361-ad9364.html?s_tid=answers_rc2-1_p4_MLT which sends an image file over SDR, but I am trying to send audio data then it has RESHAPE error with the rxAudio.
This is the whole adapted matlab code.
Please help!
dpb
dpb el 23 de Abr. de 2018
Editada: dpb el 23 de Abr. de 2018

Can't do anything without input; again set a breakpoint in the editor and step through the code and see where it breaks or use

dbstop if error

and then run the code and it will stop on the error at which point you can investigate.

You haven't even told us which of the several reshape lines threw the error; what are we supposed to do, purchase the Crystal Ball Toolbox?

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 23 de Abr. de 2018
Editada: dpb el 23 de Abr. de 2018
Well, if I just make up a .wav file and try your code on it I find
[fData,Fs] = audioread('handel.wav');
orig_size = size(fData);
binData = dec2bin(typecast(single(fData(:)),'uint8'),8);
txAudio = reshape((binData-'0').',1,[]).'; % Create binary stream
str = reshape(sprintf('%d',rxData(1:length(txAudio))),8,[]).';
decdata = uint8(bin2dec(str));
rxAudio = reshape(decdata,orig_size);
Undefined function or variable 'rxData'.
>>
In which the data argument for the reshape in
str = reshape(sprintf('%d',rxData(1:length(txAudio))),8,[]).';
isn't defined; ergo, I'm going to guess you have a variable rxData in your workspace that isn't of the same size as was the input file you read and that's the problem.
Add
clear
to your script file and I'll bet the symptoms change.
However, don't think that will likely solve your problem entirely as when you get through with the line
binData = dec2bin(typecast(single(fData(:)),'uint8'),8);
the size of binData is going to be 32x that of fData
I've really no idea what any of the above is really intended to do but it's got some serious issues...

Categorías

Más información sobre Signal Processing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by