how do I plot 2 matrix with different n of row and column (both are 9 x 6)
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Luis Duprat
el 11 de Jul. de 2020
Comentada: Luis Duprat
el 13 de Jul. de 2020
I have both matrix...just wanna do a scatter plot with them...plot (SO, PO, 'o') but the last 3 rows does not appear in the graph.
S0 = [0.50 0.40 1.10 0.20 0.50 3.40;...
0.30 0.30 0.50 0.80 1.20 9.20;...
0.20 0.10 0.20 1.10 2.40 2.50;...
0.20 0.00 0.60 2.70 7.20 16.00;...
0.10 1.10 1.90 1.10 1.50 0.40;...
1.30 1.40 2.70 3.80 7.10 6.30;...
3.00 2.70 2.60 2.80 1.80 1.80;...
1.8 1.4 0.70 0.30 0.90 0.7;...
0.70 15.10 14.70 6.10 3.10 2.20];
PO = [104.3 79.4 20.5 18.6 76.2 284.9;...
56.1 71.5 31.5 28.3 26.2 217.9;...
253.5 151.8 41.3 35.8 47.3 39.5;...
27.9 25.3 20.6 18.7 60.5 259.2;...
19.0 39.0 206. 198.7 123.7 50.3;...
41.4 156.3 171.2 206.4 84.0 38.8;...
92.2 30.7 66.4 37.1 38.4 100.9;...
10.4 17.0 50.1 36.6 43.8 38.9;...
4.1 270.2 156.1 17.7 10.1 19.8];
0 comentarios
Respuesta aceptada
Image Analyst
el 11 de Jul. de 2020
Try this:
fontSize = 15;
SO = [0.30 0.30 0.50 0.80 1.20 9.20;...
0.20 0.10 0.20 1.10 2.40 2.50;...
0.20 0.00 0.60 2.70 7.20 16.00;...
0.10 1.10 1.90 1.10 1.50 0.40;...
1.30 1.40 2.70 3.80 7.10 6.30;...
3.00 2.70 2.60 2.80 1.80 1.80;...
1.8 1.4 0.70 0.30 0.90 0.7;...
0.70 15.10 14.70 6.10 3.10 2.20];
PO = [104.3 79.4 20.5 18.6 76.2 284.9;...
56.1 71.5 31.5 28.3 26.2 217.9;...
253.5 151.8 41.3 35.8 47.3 39.5;...
27.9 25.3 20.6 18.7 60.5 259.2;...
19.0 39.0 206. 198.7 123.7 50.3;...
41.4 156.3 171.2 206.4 84.0 38.8;...
92.2 30.7 66.4 37.1 38.4 100.9;...
10.4 17.0 50.1 36.6 43.8 38.9;...
4.1 270.2 156.1 17.7 10.1 19.8];
sz = min(size(SO), size(PO))
% Get colors for each row
cmap = jet(sz(1));
for row = 1 : sz(1) % For as many rows as the one with the fewest rows has...
% Get the data from this row only.
thisSO = SO(row, :);
thisPO = PO(row, :);
% Get a unique color for the spots of this row.
thisColor = cmap(row, :);
% Make a scatterplot of the points in this row only.
scatter(thisSO, thisPO, 50, thisColor, 'filled');
hold on;
legendStrings{row} = sprintf('Row %d', row);
end
xlabel('SO', 'FontSize', fontSize);
ylabel('PO', 'FontSize', fontSize);
grid on;
legend(legendStrings);
3 comentarios
Image Analyst
el 12 de Jul. de 2020
OK, but my code will still work as is. You just have to change the one variable name from SO to S0 because you changed the name. Here is the new code:
fontSize = 15;
S0 = [0.50 0.40 1.10 0.20 0.50 3.40;...
0.30 0.30 0.50 0.80 1.20 9.20;...
0.20 0.10 0.20 1.10 2.40 2.50;...
0.20 0.00 0.60 2.70 7.20 16.00;...
0.10 1.10 1.90 1.10 1.50 0.40;...
1.30 1.40 2.70 3.80 7.10 6.30;...
3.00 2.70 2.60 2.80 1.80 1.80;...
1.8 1.4 0.70 0.30 0.90 0.7;...
0.70 15.10 14.70 6.10 3.10 2.20];
PO = [104.3 79.4 20.5 18.6 76.2 284.9;...
56.1 71.5 31.5 28.3 26.2 217.9;...
253.5 151.8 41.3 35.8 47.3 39.5;...
27.9 25.3 20.6 18.7 60.5 259.2;...
19.0 39.0 206. 198.7 123.7 50.3;...
41.4 156.3 171.2 206.4 84.0 38.8;...
92.2 30.7 66.4 37.1 38.4 100.9;...
10.4 17.0 50.1 36.6 43.8 38.9;...
4.1 270.2 156.1 17.7 10.1 19.8];
fontSize = 15;
sz = min(size(S0), size(PO))
% Get colors for each row
cmap = jet(sz(1));
for row = 1 : sz(1) % For as many rows as the one with the fewest rows has...
% Get the data from this row only.
thisSO = S0(row, :);
thisPO = PO(row, :);
% Get a unique color for the spots of this row.
thisColor = cmap(row, :);
% Make a scatterplot of the points in this row only.
scatter(thisSO, thisPO, 50, thisColor, 'filled');
hold on;
legendStrings{row} = sprintf('Row %d', row);
end
xlabel('SO', 'FontSize', fontSize);
ylabel('PO', 'FontSize', fontSize);
grid on;
legend(legendStrings);
Is there some reason this is not what you're looking for? Like maybe you want no legend, or a different colormap or something? If so, please say what you want.
Más respuestas (1)
madhan ravi
el 11 de Jul. de 2020
Editada: madhan ravi
el 11 de Jul. de 2020
SO only has 8 rows. And Ofcourse supply matrices as a vector using (:)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices 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!