MATLAB Answers

How to add value to end of array in Simulink?

10 views (last 30 days)
J.Red on 10 May 2016
I have a GPS spitting out one character at a time. I want to, in simulink, add the characters to an array until the end of the line is reached '/r/n'.
Basically, GPS_Char is my one character as read from my RX line;
void loop(){
int i = 0;
if (GPS_Serial.available()){
if (GPS_Char != '/n' && i < 80){ //the size of the longest sentence that i care about
//output gps_string to another function}
I tried to make a function that is passed the GPS_Char but I don't know how to keep the GPS_Sentence vector.
For simplicity sake, I'm using a function that outputs 1 character at a time out of a predetermined string. I want to put the string back together by reading only one character at a time! ...the countOut is just fed back into the function (as count) with a unit delay.
function [y,countOut] = fcn(count)
gps = '$GPGGA,111636.932,2447.0949,N,12100.5223,E,1,11,0.8,118.2,M,,,,0000*02';
if count > length(gps)
count = 1;
y = uint8(gps(count));
countOut = count + 1;


Sign in to comment.

Answers (0)