Quantcast

How to Store Data Detected by Octave

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to Store Data Detected by Octave

GuiCintraAlves
I'm using a barometer in an arduino where it gives me 4 variables.
I can read in the octave using the code:

clear;
pkg load instrument-control
 s1 = serial("/dev/ttyACM0",9600 );
data = srl_read(s1,3000);
s1 = char(data)
...........................................
Temperatura = 26.90 *C
Pressao = 94474 Pa
Altitude = 585.79 metros
Altitude real = 600.34 metros

And... i need plot it. How i can store  and plot??
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to Store Data Detected by Octave

Ron.Simonson

On 03/08/2017 03:29 PM, GuiCintraAlves wrote:

> I'm using a barometer in an arduino where it gives me 4 variables.
> I can read in the octave using the code:
>
> clear;
> pkg load instrument-control
>   s1 = serial("/dev/ttyACM0",9600 );
> data = srl_read(s1,3000);
> s1 = char(data)
> ...........................................
> Temperatura = 26.90 *C
> Pressao = 94474 Pa
> Altitude = 585.79 metros
> Altitude real = 600.34 metros
>
> And... i need plot it. How i can store  and plot??
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/How-to-Store-Data-Detected-by-Octave-tp4682233.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-octave
>
My preference is to separate data collection, and data plotting.  I
would probably do something
like the following:

[t, p, a, ar] = sscanf(s1, "Temperatura = %f *C\nPressao = %f
Pa\nAltitude = %f metros\nAltitude
  real = %f metros", "C");

outfile = "mydata.dat";
fpwrite = fopen(outfile, "w");
fprintf(fpwrite, "%#5.2f  %#6d  %#6.2f  %#6.2f\n",
                  t, p, a, ar);
printf("%#5.2f  %#6d  %#6.2f  %#6.2f\n",
                  t, p, a, ar);
fflush(fpwrite);
fclose(fpwrite);

and then, use gnuplot for plotting as shown in the attached plt file.

Hope this helps to get you started.

Ron.



_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

datascan.plt (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to Store Data Detected by Octave

GuiCintraAlves
I used the code, but .... I think don't know if  apply the Code

clear;
pkg load instrument-control
s1 = serial("/dev/ttyACM0",9600 );                        
data = srl_read(s1,100);
s1 = char(data)
[t,p,a,ar,100]= sscanf("temperatura = " ,"Pressao = ","Altitude", "Altirude real = ")
..................................................................................................................
> leitura_BPM085

parse error near line 9 of file /home/gui/octave/leitura_BPM085.m

  invalid left hand side of assignment

>>> [t,p,a,ar,100]= sscanf("temperatura = " ,"Pressao = ","Altitude", "Altirude real = ")
                       
                                       OR


>> leitura_BPM085

error: unterminated character string constant
parse error near line 11 of file /home/gui/octave/leitura_BPM085.m

  syntax error


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to Store Data Detected by Octave

Ron.Simonson

On 03/09/2017 04:04 AM, GuiCintraAlves wrote:

> I used the code, but .... I think don't know if  apply the Code
>
> clear;
> pkg load instrument-control
> s1 = serial("/dev/ttyACM0",9600 );
> data = srl_read(s1,100);
> s1 = char(data)
> [t,p,a,ar,100]= sscanf("temperatura = " ,"Pressao = ","Altitude", "Altirude
> real = ")
> ..................................................................................................................
>> leitura_BPM085
> parse error near line 9 of file /home/gui/octave/leitura_BPM085.m
>
>    invalid left hand side of assignment
>
>>>> [t,p,a,ar,100]= sscanf("temperatura = " ,"Pressao = ","Altitude",
>>>> "Altirude real = ")
>                          
>                                        * OR*
>
>
>>> leitura_BPM085
> error: unterminated character string constant
> parse error near line 11 of file /home/gui/octave/leitura_BPM085.m
>
>    syntax error
>
>
>
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/How-to-Store-Data-Detected-by-Octave-tp4682233p4682255.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-octave
>
It appears that the sscanf() invocation was broken.  Let's see if the
call survives
as an attachment.

Best of luck.  Ron.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

datascan.m (943 bytes) Download Attachment
Loading...