I am trying to plot real time data on appdesigner but i have always the same error. Hope somebody can help me! Here is a picture with the error and part of the program. I make a vector with the data that i am receiving by serial, and a counter to make the y axis of the graphic.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 10월 23일

1 개 추천

We can see from some of the earlier code that plot.bateria is a cell array. You cannot plot() a cell array.

댓글 수: 4

I make a array to plot while i am recieving the data. sensorbateria it a num, so if i make a array atributing num values to a new variable i am making a num array. Am i right?
You have
app.plotbateria{app.x+1} = app.sensorbateria;
The {} indicate a cell array, and cell array cannot be directly plot()
If app.sensorbateria is a scalar, then you should use
app.plotbateria(app.x+1) = app.sensorbateria;
so that you would be creating a numeric array. Numeric arrays can be plot()'d
Rizwan Khan
Rizwan Khan 2020년 9월 5일
So how do you plot a cell array?
How do you change the data type to be a number, or export it to another variable or what?
hold on
cellfun(@plot, app.plotbateria)
hold off
This exact form depends upon each entry in the cell app.plotbateria being non-scalar, and depends upon the x axes to use being 1 to the number of entries (vector) or 1 to the number of rows (2D). There are adjustments you can make such as
hold on
cellfun(@(Y) plot(Y, '*-'), app.plotbateria)
hold off
which does not depend upon app.bateria being non-scalar (it will plot markers for all points, including when the cell only has a single point). However, it uses the same line style and marker for each line.
If you have the possibility of scalar values in some of the cells, then you are probably better off using a loop in which you plot() one cell at a time, with your own control over the combination of line styles and line color and marker color that you want to use.

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

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2016년 10월 22일

댓글:

2020년 9월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by