Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

about data acquisition tool

Asked by Usman

Usman (view profile)

on 27 Jul 2013

i write a matlab code to take input though sound card. When i run this code i get 2 type of error in two different PC,s Please help me for this any one Code is this

AI=analoginput('winsound');
addchannel(AI,1);
Fs = 8000;
set(AI,'SampleRate',Fs)
duration = 2;
set(AI,'SamplesPerTrigger',duration*Fs);
start(AI);
data=getdata(AI);
delete(AI)
xfft = abs(fft(data));
mag = 20*log10(xfft);
mag = mag(1:end/2);
[ymax,maxindex]=max(mag);

When i Run this I get this error

Error
??? Error: "data" was previously used as a variable,
 conflicting with its use here as the name of a function or command.
 See MATLAB Programming, "How MATLAB Recognizes Function Calls That
 Use Command Syntax" for details.

This error in old pc and second error in new pc is this

??? Error using ==> playsnd
Frequency must be a scalar
Error in ==> sound at 58
playsnd(y,fs,bits);

1 Comment

Walter Roberson

Walter Roberson (view profile)

on 27 Jul 2013

The code you show us does not have any call to playsnd() . Perhaps your actual code is longer than this?

Usman

Usman (view profile)

Products

No products are associated with this question.

0 Answers

Contact us