Pages: [1]   Go Down
Author Topic: Sampling rate and Matlab  (Read 729 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a way to run the arduino from matlab for a specific amount of time and read from the analog pin at a specific sampling rate. I'm having trouble coding this. The code I used does not produce consistent rate for sampling which is not ideal.

Thanks.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The code I used does not produce consistent rate for sampling which is not ideal.
So, I'm not going to show it to you...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

code i had:

a_pin = 0;
tic;
i=0;

while toc < 20
   
    i = i + 1;
   
    time(i) = toc;
   
    v(i) = a.analogRead(a_pin);
   
    figure(1);
   
    plot(time,v,'r');
   
    pause(.25);
   
end
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Two things.
Post real code not just rubbish and post all of it.
Post it correctly, read the how to use this forum sticky.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Post real code not just rubbish and post all of it.
I think that is supposed to be the MatLab code. If so, it's not necessarily rubbish. It is incomplete, though.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Post real code not just rubbish and post all of it.

That is all the code... it's written in matlab... ever heard of it? If you can't answer the question no need to be nasty. 
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
That is all the code.
Really?

Code:
while toc < 20
Where it toc defined? Where is it initialized? Where is it incremented?

Is there no code on the Arduino?

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is a built in matlab function. Im controlling my arduino with matlab. Its ok I got it to work the way i wanted... people on this forum can be real sassy though !
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That is all the code... it's written in matlab... ever heard of it? If you can't answer the question no need to be nasty. 
Yes I have heard of Matlab but I do not recognise the code. A simple "this is my Matlab code" would have been so much better instead of assuming that everyone knows what Matlab code looks like.

This is an Arduino Forum not a Matlab Forum.
Do not assume that everyone knows what you do we are not mind readers here.

Quote
people on this forum can be real sassy though !
We can with people who ask for help without the common curtsey of bothering to read the "How to use this forum" sticky post and then getting shirty when it is pointed out to them.
Logged

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Curtsy is very uncommon, agreed.

 smiley-twist
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Pages: [1]   Go Up
Jump to: