MATLAB: Query regarding linspace

linspace

the book code says
A = linspace(0, 0.9, (length(y)*0.2)); %rise 20% of signal
D = linspace(0.9, 0.8,(length(y)*0.05)); %drop of 5% of signal
S = linspace(0.8, 0.8,(length(y)*0.4)); %delay of 40% of signal
R = linspace(0.8, 0,(length(y)*0.35)); %drop of 35% of signal
y is a tone signal of music
if i change the first two values of linspace, there is no change in audio. what is purpose of linspace in this command

Best Answer

Without more context, it's hard to say how they are using these vectors, but linspace() is just creating a linearly-spaced vector from A to B using the specified number of points. The spacing between points obviously depends on the starting and stopping points and the total number of samples (elements).
A = linspace(0,0.9,(length(y)*0.2));
Says "create a vector of linearly-spaced increments from 0 to 0.9 that is 20% of the length of y."
D = linspace(0.9, 0.8,(length(y)*0.05));
Create a vector that goes down from 0.9 to 0.8 using the number of points equal to 5% of the length of y.
S = linspace(0.8, 0.8,(length(y)*0.4));
The above is just a vector of the same value, 0.8, that is 40% of the length of y -- [0.8 0.8 0.8 .... ]
Related Question