Error using vertcat Dimensions of arrays being concatenated are not consistent.

3 Ansichten (letzte 30 Tage)
The problem seems to be with array concatenation. I dont understand how can this be fixed as I am not very fluent in Matlab
%Clear and clc commands to avoid data overwrite or damage
clear;
clc;
%Reading the .wav mono audio file as a "vector"
[s, F] = audioread('audiofile1.m4a');
%Setting the amplitude of the coming echos
A=0.9;
%Setting the vaule of the delay
L = 0.8*F;
%Generating and adding the echo
s = [s; zeros(20*L,1)];
sn = zeros(length(s),1);
sn=s+(A.*circshift(s,L));
%Playing the new echoed audio
sound(sn,F);
%Plotting the original plot versus the new one of the audios
plot(s);
subplot(2,1,1);
plot(sn);
subplot(2,1,2);
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in (line 11)
s = [s; zeros(20*L,1)];
  4 Kommentare
Sindar
Sindar am 7 Mai 2020
Then you can only horizontally catenate objects of size 214976xN to it. Looking closer, it's unclear what you plan to do with that line, since L is only coincidentally an integer
This would add a column of zeros to s:
s = [s; zeros(size(s,1),1)];
Mahmoud Fadel
Mahmoud Fadel am 7 Mai 2020
I added this line but unfortunately it still isn't working
I tried another audio file and size(s) had only 1 column.
Could it be that audiofile1.wav isn't mono? if so, how can I read into s as such?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Mahesh Taparia
Mahesh Taparia am 11 Mai 2020
Hi
By looking at your code,
s = [s; zeros(20*L,1)];
you want to append the rows which consists of zeros. You have mentioned in the comments that the size of s is 214976X2. So the number of columns in appending rows should be 2, i.e it should be
s = [s; zeros(20*L,2)];

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by