Can plot markers be specified in an array?
2 Kommentare
Akzeptierte Antwort
Weitere Antworten (3)
14 Kommentare
0 Stimmen
Hi @GS,
To address your query regarding, “ I want to plot data from rows of a matrix using a separate marker for each row. I tried defining a string array and a cell array, like you can do with the legend command, but I got an error with both. It seems that the only way to do this is line by line, i.e., plot(x,row1,marker1,x,row2,marker2,...). Surely there is a better way.”
Please see my response to your comments below.
First, create a sample data matrix dataMatrix with 5 rows and 10 columns filled with random values using rand(). I defined the variable x to represent the x-axis values, which correspond to the columns of the matrix. Then, name a cell array as markers containing different marker styles: circles, squares, triangles, diamonds, and crosses which will allow to assign a unique marker to each row of the matrix. Then, initiate a new figure and use hold on to ensure that all plots are displayed on the same graph without overwriting previous plots. Loop through rows by iteration row of the dataMatrix. Inside the loop, call the plot() function to plot the current row against the x-values, using the corresponding marker from the markers array and set the DisplayPropertyName to label each row for the legend. After the loop, call hold off to stop adding to the current plot. Then, label the axes, set a title for the plot, and display the legend using legend show and use grid on to enhance the readability of the plot.
Please see attached.


If you have any further questions, please let us know.
Kategorien
Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






