Unable to perform assignment because the indices on the left side are not compatible with the size of the right side

1 view (last 30 days)
for jk=1:1:length(pliki)
tak=0;
p0=pliki(jk);
p00=char(p0);
pl0=(strcat(sciezka,pliki(jk)));
tab_plikow(jk)=pl0;
plik0=char(pl0);
Thats the part of old code i need to change but don't know how. tab_plikow has:"appears to change size on every loop iteration, consider preallocating". Was trying with zeroes for tab_plikow but it doesn't seems to work or I'm doing something wrong. Any help would be appreciated, thanks.
  6 Comments

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 20 Nov 2018
Edited: Walter Roberson on 18 May 2021
unless sciezka is empty then the result of the strcat will be a character vector of at least two char. You try to store the two char into a single numeric location .
Use cell arrays or string objects .
  7 Comments
Piotr Matysiak
Piotr Matysiak on 4 Dec 2018
Actually I am using third output in code.. Look here
[y1,fs,b]=audioread(plik0);
lk1=size(y1);lk=lk1(2);
plik1=sprintf('%s',sciezka_start,'\Temp\temp1.wav');
audiowrite(y1,plik1,b);
if fs~=8000 | lk~=1 | b~=16
konw;
k_tekst0=sprintf('%s','Parametry pliku ',plik0,' :');
k_tekst1=sprintf('%s','Częstotliwość próbkowania: ',num2str(fs));
k_tekst2=sprintf('%s','Ilość bitów: ',num2str(b));
k_tekst3=sprintf('%s','Liczba kanałów: ',num2str(lk));
So how can i use audioinfo() and b output?
And second question, why tab_plikow is giving me this when i run program
tab_plikow =
1×10 cell array
Columns 1 through 5
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
Columns 6 through 10
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
Walter Roberson
Walter Roberson on 4 Dec 2018
The third parameter to audiowrite() is the the sample rate, fs, not the bits per sample.
info = audioinfo(plik0);
if isfield(info, 'BitsPerSample')
b = info.BitsPerSample;
else
b = nan;
end
Does your code still have
tab_plikow = zeros(length(pliki),1);
If it does then what does kown do ? Is it possibly a script that overwrites tab_plikow ?

Sign in to comment.


Image Analyst
Image Analyst on 20 Nov 2018
Try this
tab_plikow = zeros(1, length(pliki));

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!