Haz una pregunta
  Foros de Electrónica » Diseño digital » Interfaces y Programación
Foros Registrarse ¿Olvidaste tu contraseña?

Temas similares

07/08/2011 #1


Afinador usando matlab
Hola gente de foro de electronica , recurro a uds para que me ayuden a correguir el siguiente codigo en matlab para la simulacion de un afinador. gracias.

Código:
clear all, clc;

x = 1;

while x == 1,

x = isempty (input ('Press enter to start program or press zero to quit. "));

ghighE = 1318.1505;

gB = 987.7669;

gG = 783.9911;

gD = 587.3297;

gA = 440;

glow = 329.6277;

guitar = [ghighE, gB, gG, gD, gA, glow];

if x == 1,

p = input ('Which are you Adjusting string? 1 = e 2 = B 3 = G 4 = D 5 = ​​A 6 = E');

guitar w = (p)

y = isempty (input ('Press enter to record input signal or 0 to start over. "));

while y == 1,

% Input signal record

Fs = 44100;

T = 0:1: Fs/2-1;

I = wavrecord (Fs);

% To compare frequencies of a save file stored

Let's hear the % input signal

display ('This is how the input signal sounds.');

sound (I, Fs);

% Fft of input signal

J = fft (I) / size (I, 1);

K = 0:1: Fs/2-1; 

if p == 6

for i = 400: size (J, 1)

J (i, 1) = 0;

end

else

for i = 1500: size (J, 1)

J (i, 1) = 0;

end

end

% Plotting

subplot (2,1,1), plot (I);

subplot (2,1,2), plot (K, 2 * real (J (1: Fs / 2)));

if p == 6

axis ([200 500 -0.01 0.01])

for i = 400: size (J, 1)

J (i, 1) = 0;

end

elseif p == 5

axis ([400 550 -0.01 0.01])

for i = 550: size (J, 1)

J (i, 1) = 0;

end

elseif p == 4

axis ([450 700 -0.01 0.01])

for i = 700: size (J, 1)

J (i, 1) = 0;

end

elseif p == 3

axis ([650 850 -0.01 0.01])

for i = 900: size (J, 1)

J (i, 1) = 0;

end

elseif p == 2

axis ([800 1100 -0.01 0.01])

for i = 1200: size (J, 1)

J (i, 1) = 0;

end

elseif p == 1

axis ([1200 1400 -0.01 0.01])

for i = 1500: size (J, 1)

J (i, 1) = 0;

end

end

% Xlabel ('Frequency (Hz)') ylabel ('Amplitude (V)');

% Title ('input signal'); 


K = 0:1: (Fs/2-1);

(1.0015 * w)

K (find (J == max (J)))

(0.9985 * w)

z = ((K (find (J == max (J)))-w) / w) * 100;

if (1.0015 * w)> K (find (J == max (J )))&& (0.9985 * w) <K (find (J == max (J))),

display ('Perfect Intonation !!!');

disp (['The frequency of the input signal is,', num2str (K (find (J == max (J)))) 'Hz']);

fprintf ('Percent Error% d%% \ n', z)

elseif w> K (find (J == max (J))),

display ('Input Should Be INCREASED frequency');

disp (['The frequency of the input signal is,', num2str (K (find (J == max (J)))) 'Hz']);

fprintf ('Percent Error% d%% \ n', z)

elseif w <K (find (J == max (J))),

display ('Input Should Be Decreased frequency');

disp (['The frequency of the input signal is,', num2str (K (find (J == max (J)))) 'Hz']);

fprintf ('Percent Error% d%% \ n', z)

            

end

y = isempty (input ('Make needed adjustments and press enter to record a new input signal or 0 to start over. "));

if y == 1,

continue;

else x = 1;

end

end

end

end
Respuesta
¿Tienes una mejor respuesta a este tema? ¿Quieres hacerle una pregunta a nuestra comunidad y sus expertos? Registrate

Buscar más temas sobre:
Lupa Interfaces y Programación

Lenguajes de programación, gestión y manejo de puertos

Cerrar
Foros de Electrónica » Diseño digital » Interfaces y Programación

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2011, Crawlability, Inc.