MATLAB: ??? Error using ones Maximum variable size allowed by the program is exceeded. Quantization_Try (line 18) y1 = ones(1:d1)

errormaximum variable size exceed.

*Cannot figure out why?? Info :: matrix dimension of y = 1 ,384752*
|clc;
clear all;
close all;
y1 = audioread('C:\Users\Sumit\Desktop\emma.wav');
L1 = input('Enter the levels : ');
y = y1(:,1);
Max = max(y);
Min = min(y);
L = zeros(1,L1);
x1= abs(Max-Min);
x=abs(x1/(L1-1));
L(1)= min(y);
for n=2:L1
L(n)=L(n-1)+x;
end
[d1,d2]=size(y);
y1 = ones(1:d1) %%This is line 18 (Problem Here)
for n1=1:d1
for n2=1:L1
if(y(n1) >= L(n1)) && (y(n1) <= L(n1+1))
y1(n1)= L(n1+1);
end
end
end
plot(y1);|

Best Answer

You’re asking it to create a ‘d1’-dimensional matrix, equivalent to ones(1,2,3,...,d1).
Try this instead:
y1 = ones(1,d1);