Re-hash the intrinsic Matlab plot function to accept a string as a y input?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using the matlab 'plot' function which uses x, y as inputs. The x axis is time (which is a number in seconds and is easy), however the y axis is actually a number/string combination, for example, E312, E313. The plot function breaks since it is only expecting a numeric value, however I want the ylabel (for that corresponding point) to display 'E312' (in this example); how is that possibe?
2 commentaires
Walter Roberson
le 17 Avr 2019
If I have (say) 500 pixels available for y axes, then how far up should 'E312' appear? How far up should 'E313' appear? Is 'E1000' above or below 'E2' ?
Réponses (1)
Steven Lord
le 17 Avr 2019
You could turn your text data into a categorical array then plot with that categorical data as the Y input.
colors = categorical({'r' 'b' 'g', 'g' 'r' 'b', 'b' 'r' 'g'}, ...
{'r' 'g' 'b'},{'red' 'green' 'blue'});
plot(1:9, colors)
Alternately, if you want to plot numeric data and just have the labels on the axes change, use the yticklabels function.
1 commentaire
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!