I have "classes", and "inputs" array. Both of arrays' dimensions are 1x2000.
In "classes" array, the clusters of data in "inputs" array are recorded. For instance,
classes = [5, 2, 4, 3, 5, ...]
inputs = [5.234, 6.345, 4.342, 2.532, 5.345, ...]
When I plot "inputs" array like plot(inputs)
, I want to differently color each data which correspond to the specific clusters in "classes" array.
How can I manage this?
Thanks.
The simplest solution is to do something like:
x = 1:numel(inputs);
plot(x(classes == 1), inputs(classes == 1), '.b',
x(classes == 2), inputs(classes == 2), '.g',
x(classes == 3), inputs(classes == 3), '.r');
You can expand on this idea, such as looping over the classes, customizing color ordering, and more. Please add more information to your question if you want a more specific or detailed answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.