draw 4d vision graph for this matrix

2 ビュー (過去 30 日間)
mirewuti muhetaer 2020 年 2 月 9 日
コメント済み: mirewuti muhetaer 2020 年 2 月 21 日
Hi,
I have a matrix in this form:
%%%%%%%%%%%%%%%%%%%%%
a b c
x1 a11 a12 a13
x1 a21 a22 a23
x1 a31 a32 a33
%%%%%%%%%%%%%%%%%%%%%
In the above, x1 is a 20 by 1 row. I wanted to draw the 4d graph to make more visilized the result. But when i was following the first example in https://www.mathworks.com/help/matlab/visualize/visualizing-four-dimensional-data.html, it always fails to generate whole plot ( just producing the last one or say the size is out of bound). Can someone help me for this.?
Thanks
2 件のコメント表示 1 件の古いコメント非表示 1 件の古いコメント
mirewuti muhetaer 2020 年 2 月 12 日
Dear John:
I attached the xlsx file in below. The fist row(from 2d to 5th column) is a variable called A. The frist column(except first input) is the three(corresponding to some variable called C) time repeation of the inflation index, And the second row to last raw, second column to last column is the corresponding values called B.
So, i want a 4d vision such that A, B and inflation index as the x, y, and z axis. Then draw the graph for three different values for C.
I would really appreciate if you could help.

サインインしてコメントする。

採用された回答

Githin John 2020 年 2 月 21 日
Looking at the data you shared, the different columns of B have very different ranges. For example, column 3 of B has data in the 1e-4 range while the 4th column has data in the -16 range. So plotting all this data in a single plot (something similar to what is done in the link you shared) may not be the best approach. Also the difference in values between each time iteration is very small. So if you plot it all in the same graph, you may not be able to notice the variations. You may try using the subplot to get a plot like below. Each plot is for one value of A.
subplot(4,1,1);
scatter(C,B(:,1),'r')
subplot(4,1,2);
scatter(C,B(:,2),'b')
subplot(4,1,3);
scatter(C,B(:,4),'g')
subplot(4,1,4);
scatter(C,B(:,3),'c')
However, if you wished to make a 4D plot. you could something like this
C1B1=B(1:21,1);
C1B2=B(1:21,2);
C1B3=B(1:21,3);
C1B4=B(1:21,4);
C2B1=B(22:42,1);
C2B2=B(22:42,2);
C2B3=B(22:42,3);
C2B4=B(22:42,4);
C3B1=B(43:63,1);
C3B2=B(43:63,2);
C3B3=B(43:63,3);
C3B4=B(43:63,4);
C1=C(1:21);
C2=C(22:42);
C3=C(43:63);
A1=A(1)*ones(21,1);
A2=A(2)*ones(21,1);
A3=A(3)*ones(21,1);
A4=A(4)*ones(21,1);
plot3(C(1:21),A1,C1B1,'r*')
grid on
hold on
plot3(C1,A2,C1B2,'r-')
plot3(C1,A3,C1B3,'r-.')
plot3(C1,A4,C1B4,'ro')
plot3(C2,A1,C2B1,'b*')
plot3(C2,A2,C2B2,'b-')
plot3(C2,A3,C2B3,'b-.')
plot3(C2,A4,C2B4,'bo')
plot3(C3,A1,C3B1,'g*')
plot3(C3,A2,C3B2,'g-')
plot3(C3,A3,C3B3,'g-.')
plot3(C3,A4,C3B4,'go')
xlabel('C');
ylabel('A');
zlabel('B');
Where, A are the 4 values in row 1. B is the 63x4 matrix from the excel sheet. C is the 63x1 values of repeated time iteration.
1 件のコメント表示 なし非表示 なし
mirewuti muhetaer 2020 年 2 月 21 日
Dear John:
Thanks so much. The first graph makes more sense. Thanks for your help.

サインインしてコメントする。

カテゴリ

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by