Go Down

### Topic: Sampling rate and Matlab (Read 1 time)previous topic - next topic

#### Troody

##### Jun 22, 2013, 06:45 pm
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.

#### PaulS

#1
##### Jun 23, 2013, 03:07 pm
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...

#### Troody

#2
##### Jun 23, 2013, 04:42 pm
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

#### Grumpy_Mike

#3
##### Jun 23, 2013, 05:08 pm
Two things.
Post real code not just rubbish and post all of it.
Post it correctly, read the how to use this forum sticky.

#### PaulS

#4
##### Jun 23, 2013, 05:14 pm
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.

#### Troody

#5
##### Jun 24, 2013, 12:18 am

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.

#### PaulS

#6
##### Jun 24, 2013, 12:25 am
Quote
That is all the code.

Really?

Code: [Select]
`while toc < 20`
Where it toc defined? Where is it initialized? Where is it incremented?

Is there no code on the Arduino?

#### Troody

#7
##### Jun 24, 2013, 12:34 am
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 !

#### Grumpy_Mike

#8
##### Jun 24, 2013, 08:31 am

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.

#### aarondc

#9
##### Jun 24, 2013, 09:33 am
Curtsy is very uncommon, agreed.

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

Go Up

Please enter a valid email to subscribe

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy