필터 지우기
필터 지우기

Real time vector saving

조회 수: 1 (최근 30일)
Stergios Verros
Stergios Verros 2016년 9월 30일
답변: Brandon Eidson 2016년 10월 6일
Dear all,
I am using xPC with R2014b version and in my model I have a state machine that in one state there is a function with two inputs coming from 2 sensors. I want to save all the values of the inputs into 2 vectors (eg. 10,1) that I will use in an other state.
Until now I used a persistent variable for the index for the vectors. My question is: how is it possible to save the 2 vectors and use them in the next state?
Bests, Stergios
  댓글 수: 5
Stergios Verros
Stergios Verros 2016년 10월 3일
Thank you!
Stergios Verros
Stergios Verros 2016년 10월 3일
To make it more clear, I want to make a polyfit from the 2 vectors, save the coefficients and then use them into an other state!

댓글을 달려면 로그인하십시오.

답변 (2개)

Gareth Thomas
Gareth Thomas 2016년 10월 3일
If I understand you correctly you have a stateflow chart, in which one state you are calculating some parameters for a polyfit and you want to send them to another state based on a particular condition.
Have you looked into Events in Stateflow? One can broadcast events with data to another states.
  댓글 수: 1
Stergios Verros
Stergios Verros 2016년 10월 3일
Thanks for that but my main question is one step before that.
I try to save the values in 2 vectors (1000x1) and polyfit in every cyrcle and at the last circle (before the condition) to save the coefficients. I use persistent variables but the xPC keeps giving a CPU overload. Would it be helpful to paste the code here?

댓글을 달려면 로그인하십시오.


Brandon Eidson
Brandon Eidson 2016년 10월 6일
Hey Stergios,
One way to save variables in one state that can be used in another state is by using the "Data Store Memory" block and its associated blocks. I have provided the link to its documentation below as well as a link to information on how to use this block in Stateflow.
Also, if you are using C for your Stateflow Action Language, note that the scope of variables can be handled differently. A list of some of the differences is found at the link below.

카테고리

Help CenterFile Exchange에서 Verification, Validation, and Test에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by