Matlab图形绘制 [英] Matlab Graph Plotting

查看:129
本文介绍了Matlab图形绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出t1,t2,t3,t4作为实值参数, 以及以下格式的约束:

Given t1,t2,t3,t4 as real value parameters, and the constraints of the following format:

(t1>=0 and t2>=0 and t3>=0 and t4>=0) 

((t2<=5) or (t1+t2+t3+t4<=3))

可以使用Matlab的.net库来绘制此约束吗? (我正在使用C#).

Could this constraint be plotted using the .net library of matlab? (I am using C#).

我担心的是: 1.它具有四个维度,我不确定该图如何在Matlab中表示; 2.基本上这个约束可能会导致凸多边形,可以在Matlab中绘制这样的多边形吗?

My concern is: 1. This has four dimension, I am not sure how is the graph can be represented in Matlab; 2. And basically this constraint might result in a convex polygon, can such polygon been drawn in Matlab?

我对Matlab完全陌生,因此,如果可能的话,一些代码片段和结果对我将非常有帮助.谢谢.

I am totally new in Matlab, therefore if this is possible, some code fragments and the result, would be very helpful for me. Thanks.

推荐答案

由于我不熟悉C#,因此只能解决它的Matlab方面,但是我认为Matlab .NET编译器应该能够导出所有功能?

I can only solve the Matlab side of it since I'm not familiar with C#, but I think the Matlab .NET compiler is supposed to be able to export all functions?

1:您可以使用动画3D散点图(以及表面,网格,线图等变体)绘制4维数据.如果考虑一下,一般的3D电子游戏基本上就是4D图.对于从0秒开始的散点图,仅绘制那些t4 = 0的点,其中x = t1,y = t2,z = t3.在1秒时,仅绘制t4 = 1的那些.在2秒时,只有t4 = 2,依此类推,直到达到max(t4),然后循环返回.

1: You can plot 4 dimensional data using animated 3D scatterplots (and variants like surface, mesh, line plots). Your average 3D video game, if you think about it, is a 4D plot, basically. For a scatter plot, starting at 0 seconds, draw only those points which have t4 = 0, with x=t1, y=t2, z=t3. At 1 second, plot only those with t4=1. At 2 seconds, only t4=2, and so on until you reach max(t4) and then you loop back.

您还可以将颜色用作第4维,以便在3D空间中具有彩色点.

You can also use color as the 4th dimension, so that you have colored points in 3D space.

我认为,从观点上讲,您可以将其推广到其他情节.

From points you can generalize to other plots, I think.

请参见 http://www.mathworks.com/help/techdoc/ref/scatter3.html http://www.mathworks. com/help/techdoc/ref/surf.html .

2:让我澄清一些事情.根据您的初始条件,没有坐标可以为负:

2: Let me just clarify a few things. Given your initial condition that no coordinate can be negative:

  • t2<=5定义了一个无限的4维空间的平板",该空间在3维中是无限的,在1维中是有限的(5单位厚).平板的一条边位于原点和<0, 5, 0, 0>之间,连接到原点的其他三个边沿t1t3t4轴在正方向上延伸到无穷大.
  • t1+t2+t3+t4<=3定义了一个有限的4维金字塔,其尖端在<+, +, +, +>方向上位于原点和底端.
  • t2<=5 defines an "slab" of infinite 4-dimensional space, which is infinite in 3 dimensions and finite in one (it's 5 units thick). One edge of the slab lies between the origin and <0, 5, 0, 0>, the three other edges connecting to the origin extend to infinity in the positive direction along the t1, t3 and t4 axes.
  • t1+t2+t3+t4<=3 defines a finite 4-dimensional pyramid with the tip at origin and base looking in the <+, +, +, +> direction.

鉴于您的OR,结果是这两个空格的并集. (超)金字塔已经是(超)平板的子集,因此第二个表达式是多余的.平板是微不足道的,所以我将展示如何仅可视化金字塔.

Given your OR, the result is a union of these two spaces. The (hyper)pyramid is already a subset of the (hyper)slab, so the second expression is redundant. The slab is trivial, so I will show how to visualize only the pyramid.

要形象化它,我认为您应该将t4设置为10个不同的值,并将其他3个参数分别绘制为不同颜色的表面.

To visualize it, I think you should, say, set t4 to 10 different values, and plot each of the other 3 parameters as surfaces of different color.

一个例子:

clc
clear
close all

n = 10;

% Manually calculated maximae of x, y, z axes
x = [0 0; 0 3];
y = [0 0; 3 0];
z = [3 3; 0 0];   % surf can only draw polygons, not triangles, so we just squash two points together

% Actual t will be derived from this algorithmically
t = [3 3; 3 3];

% So plots don't replace each other
hold on

for i = 0:0.1:1
    % Manually derived
    surf(x*i, y*i, z*i, t*(1-i));
end
hold off

% Just some aesthetic stuff
xlabel('t1'); 
ylabel('t2'); 
zlabel('t3');
grid on
colormap('hot')

每种颜色都是不同t4金字塔的底面(尖端在原点)-您可能会想象3D金字塔随着时间的流逝而缩小".

Each color is the base of the pyramid (tip is at origin) for a different t4 - you might imagine a 3D pyramid "shrinking" as time goes on.

我不知道它的相关性,但是在Matlab中凸多边形是完全可以的:

I don't know the relevance, but convex polygons are perfectly fine in Matlab:

plot([0 0 1 1 2 2 3 3 0], [0 2 2 1 1 2 2 0 0]); axis([-1 4 -1 4])

这篇关于Matlab图形绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆