



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




function test3sound(filename,n)
[Y Fs] = wavread(filename); L = length(Y); X = round(linspace(1,L,round(L/(2^(n/12))))); sound(Y(X), Fs)
% Alternatively the next line could be used in place of % lines 4- % sound(Y, round(Fs * 2^(n/12)))
function sounds2(filename,n) [Y Fs] = wavread(filename); L = length(Y); X = round(linspace( 1, L, round(L*n))); Ynew = Y(X); wavwrite(Ynew, Fs, ['new' filename]);
[Y Fs] = wavread('music.wav'); L = length(Y); T = L / Fs; % Total duration
Fs = 44100; t = 1/Fs:1/Fs:1; % Duration here is just assumed 1 even though not stated % in problem Y = cos(2pi(261.6).*t); sound(Y,Fs);
function ret = GreenUpsideDown(img) ret = img(end:-1:1, :,:); % flip ret = double(ret); ret(:,:,2) = (ret(:,:,1)+ret(:,:,3))./2; ret = uint8(ret);
function ret = grayscale(filename) img = imread(filename); img = double(img); ret = (img(:,:,1) + img(:,:,2) + img(:,:,3))./3; ret = uint8(ret); imshow(ret);
function test3nummeth(x,y) newx = linspace(x(1), x(end), 50); newy = spline(x,y,newx); plot(x,y,newx,newy); title('cubic spline interpolation plot'); xlabel('X values'); ylabel('Y values');
coef = polyfit(data(1,:), data(2,:), 3) x = linspace(data(1,1), data(1,end), 10 * length(data(1,:))); y = polyval(coef,x); plot(x,y);
A = interp1(t,c,[40], 'linear') coef = polyfit(t,c,2); B = polyval(coef,[40]) plot(t(2:end),diff(c)./diff(t));