Error using vertcat Dimensions of arrays being concatenated are not consistent.
3 views (last 30 days)
Show older comments
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 Comments
Sindar
on 7 May 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)];
Answers (1)
Mahesh Taparia
on 11 May 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)];
0 Comments
See Also
Categories
Find more on Audio I/O and Waveform Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!