How to merge multiple graphs/vectors in one!
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Ivan Shorokhov
il 21 Gen 2015
Commentato: Star Strider
il 21 Gen 2015
Dear All,
Code used:
figure; hold on;
plot(fliplr(x1), fliplr(y1), 'ro'); plot(x8, y8, 'rx');
plot(fliplr(x2), fliplr(y2), 'bo'); plot(fliplr(x6), fliplr(y6), 'b*');
plot(x3, y3, 'mo'); plot(x7, y7, 'mx');
plot(x4, y4, 'co'); plot(fliplr(x5), fliplr(y5), 'c*');
Note: 1. Some of the values are NaN, 2. some of coordinate are clashes with each other. I would like to combine all 8 graphs into one graph(2 arrays Xtotal and Ytotal), how can I do it?
I could use following code to find all unique values:
xall = [fliplr(x1) fliplr(x2) x3 x4 fliplr(x5) fliplr(x6) x7 x8];
[x, ~, xindices] = unique(xall);
yall = [fliplr(y1) fliplr(y2) y3 y4 fliplr(y5) fliplr(y6) y7 y8];
[y, ~, yindices] = unique(yall);
>> x<1x102 double> = [258 259 ... 353 NaN]
>> y<1x189 double> = [177 178 ... 306 NaN]
But I'm not sure how I can use it, and what to do next. Also I would like to keep all NaN in the same place, if possible.
Thanks in advance for any help,
I
0 Commenti
Risposta accettata
Star Strider
il 21 Gen 2015
Modificato: Star Strider
il 21 Gen 2015
To begin with, your data are apparently all row vectors, so I would concatenate them as cell arrays:
xall = {fliplr(x1); fliplr(x2); x3; x4; fliplr(x5); fliplr(x6); x7; x8};
yall = {fliplr(y1); fliplr(y2); y3; y4; fliplr(y5); fliplr(y6); y7; y8};
figure(1)
hold on
for k1 = 1:size(xall,1)
plot(xall{k1}, yall{k1}, 'x')
end
hold off
I would not bother with unique, since the points will simply overplot each other, since you’re plotting them as discrete points and not as lines. In R2014b, the colours will cycle automatically. Otherwise, you will have to cycle through the colours yourself, but that is not difficult.
2 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!