I have 30 tables like the ones shown below with same e1 and e2 but different error. I am not sure what is the best way to show these results. I tired heat map but seems like its not possible since e1 has repetition. Can someone help me with this.
% e1 e2 error
[0.01, 0.01, 8.287423935;
0.01, 0.1, 8.430020284;
0.01, 0.5, 8.954563895;
0.1, 0.01, -1.004665314;
0.1, 0.1, -0.611359026;
0.1, 0.5, 0.094929006];

 Respuesta aceptada

Star Strider
Star Strider el 14 de Abr. de 2018

0 votos

your data are gridded, so you can use the reshape function to convert them to the necessary matrices to plot them with surf, mesh, or contour.
Try this:
e1e2er = [0.01, 0.01, 8.287423935;
0.01, 0.1, 8.430020284;
0.01, 0.5, 8.954563895;
0.1, 0.01, -1.004665314;
0.1, 0.1, -0.611359026;
0.1, 0.5, 0.094929006];
e1r = reshape(e1e2er(:,1), 3, []);
e2r = reshape(e1e2er(:,2), 3, []);
err = reshape(e1e2er(:,3), 3, []);
figure(1)
surf(e1r, e2r, err)
grid on
view(45, 25)
xlabel('e_1')
ylabel('e_2')
zlabel('err')
It works.

6 comentarios

Isha Sharma
Isha Sharma el 18 de Abr. de 2018
Editada: Isha Sharma el 18 de Abr. de 2018
Thank you for your suggestion. It does work but I have now modified my data. As 3D plots will not give justice to the data. So instead I want to concentrate on 2D bar chat. Now what I have is three unique values of column 1: 0.01, 0.1 and 0.5. I want to plot a bar graph where x axis is 0.01,0.1 and 0.5. Y axis is column 2. I want to plot all y for x = 0.01, then x = 0.1, and finally x = 0.5. Could you please help me with this.
A1 = [
% x y
0.1, -0.611359026;
0.5, 0.094929006;
0.01, -1.004665314;
0.1, 0.944460857;
0.5, 0.944460857;
0.01, -0.979911374;
0.1, -0.649607183;
0.5, -0.643434343;
0.01, -0.012233446;
0.1, 0.689279113;
0.5, -1.594824399;
0.01, -0.024399261;
0.1, 1.033380682;
0.5, 1.033380682;
0.01, 1.033380682;
0.1, 0.963636364;
0.5, 0.963636364;
0.01, 0.124484848 ;
];
Star Strider
Star Strider el 18 de Abr. de 2018
Your ‘A1’ matrix has significant problems, specifically this line:
0.1, 0.5, 1.033380682;
since at the very least it has 3 columns while the other rows have 2, so it is not possible to create ‘A1’.
Please correct it first. Then I will see if I can create a bar3 plot from it.
Isha Sharma
Isha Sharma el 18 de Abr. de 2018
Editada: Isha Sharma el 18 de Abr. de 2018
sorry that was a typo. Table has 2 columns. I have corrected the table above.
Star Strider
Star Strider el 18 de Abr. de 2018
My pleasure.
No worries. I wanted the correct matrix before I began to work on it.
I am not certain what you want.
Try this:
C1 = reshape(A1(:,1), 3, []);
C1 = circshift(C1, [1 0]); % Optional
C2 = reshape(A1(:,2), 3, []);
C2 = circshift(C2, [1 0]); % Optional
figure(1)
bar3(C1(:,1), C2)
grid on
set(gca, 'YTick',C1(:,1), 'YTickLabels',C1(:,1))
figure(2)
bar3(C1(:,1), C2, 'grouped')
grid on
set(gca, 'YTick',C1(:,1), 'YTickLabels',C1(:,1))
title('Grouped')
figure(3)
bar3(C1(:,1), C2, 'stacked')
grid on
set(gca, 'YTick',C1(:,1), 'YTickLabels',C1(:,1))
title('Stacked')
This plots the reshaped second column of ‘A1’ as separate columns in the ‘C2’ matrix, as functions of the first column of the ‘C1’ matrix.
Experiment with them to get the result you want.
Isha Sharma
Isha Sharma el 18 de Abr. de 2018
Thanks! I will check this and edit accordingly. :)
Star Strider
Star Strider el 18 de Abr. de 2018
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de Abr. de 2018

Comentada:

el 18 de Abr. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by