Read serial port and plot Matlab graph - some characters are missing, why?

2 views (last 30 days)
Hi all,
I was trying to access serial port data sent from UART in Altera Nios II to plot graph real time in Matlab.
I wanted to plot the graph in the format of: (in Matlab code)
a = str2double(line(1:2)); %a ranged from 1 to 12 b = str2double(line(4:7)); %b is 4 digits c = str2double(line(9:10)); %c ranged from 1 to 12
Example, 01@2564;12 , so line 3 is for character @ and line 8 is for character ;
In the C code, I do something like:
int MAT1[]={0,1,10, arr[3], arr[2], arr[1],arr[0],-1,arr_index[1],arr_index[0]}; // so 10 is for character @ and -1 is for character ;
for ( i = 0 ; i < 10 ; i++ ) txdata1[i] = MAT1[i]
When I plot the graph and save it in .csv, from the excel column, correct c should be '02' but it shows only the first digit '0', how can I write the code in C to represent the ascii character so that it will display properly '2' instead of '0'?
My second question is, it appears to me that, the other possibility of getting the above error is that, the uart is only able to send the first digit instead of two digits that is why it shows only '1' when it is supposed to display '12' for c? Because, in a few occasions,I did see it display '12'
I hope someone can give me a hint of how to solve this problem, thank you in advance

Answers (1)

want2know
want2know on 18 Mar 2015
anyone please? any hint will do for me to try?

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!