query regarding linspace
Ältere Kommentare anzeigen
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
1 Kommentar
Walter Roberson
am 22 Sep. 2011
You need to be careful: linspace() always includes the first and last values in the range, so if you put D right after A, you would have two 0.9 beside each other. Sometimes that is what you want, but usually it is not.
Akzeptierte Antwort
Weitere Antworten (6)
Wayne King
am 22 Sep. 2011
You'll have to convert the cell arrays with cell2mat(), or you'll have to do something like this.
C = cell(2,1);
C{1} = randn(1e3,1);
tone = C{1}.*ones(1e3,1);
I personally recommend that you write your own little ASDR function that accepts a vector input, so you convert from a cell array to a vector outside the function or feed the function C{i} and then inside the function create your envelope and multiply your signal by it and then return your signal as the output.
1 Kommentar
moonman
am 22 Sep. 2011
moonman
am 22 Sep. 2011
Wayne King
am 22 Sep. 2011
They have created this envelope with
fs=8500;
y=sin(2*pi*300*(0:0.000117:3));
A = linspace(0, .9, (length(y)*0.25)); %rise 20% of signal
D = linspace(.9, 0.7,(length(y)*0.05)); %drop of 5% of signal
S = linspace(0.7, 0.7,(length(y)*0.40)); %delay of 40% of signal
R = linspace(0.7, 0,(length(y)*0.30)); %drop of 35% of signal
ADSR = [A D S R] ;
Then they multiply the sine wave element by elementy by ADSR. The sine wave oscillates between [-1 1], but when you multiply it element by element by the ADSR envelope, the sine wave oscillates between positive and negative values within the shape of the envelope.
moonman
am 22 Sep. 2011
1 Kommentar
Fangjun Jiang
am 22 Sep. 2011
mis-match, C is cell array, x is double array
moonman
am 22 Sep. 2011
0 Stimmen
moonman
am 22 Sep. 2011
0 Stimmen
1 Kommentar
Wayne King
am 22 Sep. 2011
I'm glad you solved your problem and you're very (too) kind. There are many here who know far,far more than me and freely give so much of their time helping people. That's what makes the MATLAB user community so great. I'm amazed at the level of knowledge here, on the newsgroup, and the file exchange. And how generously they impart that knowledge to others.
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!