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];

 채택된 답변

Star Strider
Star Strider 2018년 4월 14일

0 개 추천

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

Isha Sharma
Isha Sharma 2018년 4월 18일
편집: Isha Sharma 2018년 4월 18일
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 ;
];
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 2018년 4월 18일
편집: Isha Sharma 2018년 4월 18일
sorry that was a typo. Table has 2 columns. I have corrected the table above.
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 2018년 4월 18일
Thanks! I will check this and edit accordingly. :)
Star Strider
Star Strider 2018년 4월 18일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2018년 4월 13일

댓글:

2018년 4월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by