Error using plot, invalid data argument
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lucas Gutierrez Villas Boas
el 22 de Oct. de 2016
Comentada: Walter Roberson
el 8 de Sept. de 2020

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.
0 comentarios
Respuestas (1)
Walter Roberson
el 23 de Oct. de 2016
We can see from some of the earlier code that plot.bateria is a cell array. You cannot plot() a cell array.
4 comentarios
Rizwan Khan
el 5 de Sept. de 2020
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?
Walter Roberson
el 8 de Sept. de 2020
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.
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!