Need help with Arduino Nano 3 and Matlab!

Hi everybody!
Now i am doing a small project with Arduino Nano 3 and Matlab 2007a. Arduino Nano 3 is connected to my laptop via usb.
I used Matlab command:

a = arduino;
[code]v = readVoltage(a,'A0');

to read data from a sensor, then i plotted it in the real time, saved data in a variable of array.
to do more signal processing like filter received data...etc, i really need to know the sampling frequency.
So the main question is that:
how can i set the sampling frequency for the command "readVoltage"?
or is there any command that read the data from the Arduino Nano 3 which i can specify the sampling frequency?
thank in advance!

Where is the Arduino code? That controls the sampling frequency. Reads once per instruction.

Paul

kchientdc:
Hi everybody!
Now i am doing a small project with Arduino Nano 3 and Matlab 2007a. Arduino Nano 3 is connected to my laptop via usb.
I used Matlab command:

a = arduino;

[code]v = readVoltage(a,'A0');



to read data from a sensor, then i plotted it in the real time, saved data in a variable of array.
to do more signal processing like filter received data...etc, i really need to know the sampling frequency.
So the main question is that: 
how can i set the sampling frequency for the command "readVoltage"?
or is there any command that read the data from the Arduino Nano 3 which i can specify the sampling frequency?
thank in advance!

Sounds like you need help with Matlab programming.

Paul_KD7HB:
Where is the Arduino code? That controls the sampling frequency. Reads once per instruction.

Paul

Thanks, bro! There is not Arduino code. I code Arduino Nano by Matlab. and here are the code:

%% Connect to Arduino
% Use the arduino command to connect to an Arduino device.
clear all;
a = arduino;

%% Acquire and display live data

figure
h = animatedline;
ax = gca;
ax.YGrid = 'on';
ax.YLim = [-200 4500];
pulsenum = 0;
stop = false;
startTime = datetime('now');
tic
while ~stop
% Read current voltage value

v = readVoltage(a,'A0');
vmv = 1000*v;
t = datetime('now') - startTime;

% Get current time
% Add points to animation

addpoints(h,datenum(t),vmv)
title('Acquiring Sensor Data')
xlabel('Elapsed time (Sec)')
ylabel('Voltage (mVol)')

% Update axes
ax.XLim = datenum([t-seconds(10) t]);
datetick('x','keeplimits')
drawnow
% fprintf('Thoi diem, %s\n', t0);

% Check stop condition
stop = readDigitalPin(a,'D13');
%fprintf('So xung %d\n', pulsenum);
end

ieee488:
Sounds like you need help with Matlab programming.

So, you mean i should ask in some forum of Matlab coding?

If I recall correctly, there is a specific sketch you upload to the arduino to make it work with Matlabs commands such as the one you have shown.
In that sketch you probably need to make some provisions to enable a certain sample rate, who knows how that function is actually accessing the arduinos ADC.

But that still leaves the question, how to make the arduinos(ATmega328) ADC sample at a particular rate. Guess the datasheet would be a good place to start because I don't think Arduino is supplying a way to control the sample rate, does it?

many thanks!