How to generate a 4 D plot.
1 次查看(过去 30 天)
显示 更早的评论
Dear Friends,
We have four variables:
,
,
,
with conditions
,
. We want to plot this function
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230552/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230553/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230554/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230555/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230556/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230557/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230558/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230559/image.png)
How can we generate the plot for F?
2 个评论
Walter Roberson
2019-7-27
You have 4 independent values and 1 dependent value, so your plot would have to be 5 dimensional. Did you have some ideas on how you wanted to encode the 5 different dimensions ?
回答(2 个)
Walter Roberson
2019-7-27
vals = 0 : 0.01 : 1;
[p1, p2] = ndgrid(vals);
mask = p1 + p2 <= 1;
p1 = p1(mask);
p2 = p2(mask);
[idx1, idx2] = ndgrid(1:length(p1));
V = @(M) M(:);
x = V(p1(idx1));
y = V(p2(idx1));
u = V(p1(idx2));
v = V(p2(idx2));
Now x, y, u, v are each column vectors, and for any given index, x(K), y(K), u(K), v(K) is such that x(K)+y(K)<=1 and u(K)+v(K)<=1 . This gives you 26532801 (over 26 million) points.
You can now evaluate F in vectorized form. You can then do corrections for the cases where x and u are both 0 or y and v are both 0 or 1-x-y is 0 together with 2 - x - u - u - v being 0.
This will leave you with 26532801 x, y, u, v, F coordinate tuples.
With the data all calculated, you now have to decide what a 5 dimension plot should look like. Did you have some ideas on how you want to represent 5 dimensional data on a 2 dimensional display ?
4 个评论
John D'Errico
2019-7-27
You want to plot some function of 4 variables. So essentially, you have a 5-dimensional plot you want to see. Not gonna happen. Your monitor is TWO dimensional. We plot 3-d plots as needed, because your brain understands how to visualize a 3-d thing from a 2-d scene. You rotate it around, etc, then gaining an understanding of the object.
But you have 5 dimensions of interest. Not 2 or 3. Not even 4 (where there is one trick you can do with an iso-surface, sort of a contour plot in 3-d.) You can also play with Chernoff faces, but I have never personally found them to be of much value.
So unless you have bought one of those new holodeck monitors, available from Starfleet Command for a princely sum of federation credits (surely you can guess what it costs to ship stuff from the other side of the galaxy) you cannot visualize 5-dimensional stuff on a 2-d monitor.
I'm sorry, but we all live in sphereland. (Read the book! At least, start with Flatland, truly a fun book to read.) 5-dimensions is out of view for us common 3-d people, who can see only 3 dimensions.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!