问题描述:

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)`

and

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

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

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?

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

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: 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.

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.

See http://www.mathworks.com/help/techdoc/ref/scatter3.html and http://www.mathworks.com/help/techdoc/ref/surf.html.

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

`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.

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.

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.

An example:

```
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')
```

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.

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])
```

您可能感兴趣的文章：

- Spring security 3.2.0 RC1 csrf with multipart/form-data
- javascript - jQuery infinite loop, animate many items?
- performance - How to optimize images served through the dispatcher
- Classic ASP app not working in IIS 8.5
- iphone - How do I detect which iOS device my user is using?
- php - Reading a specific line from a text file
- clr - Any implementation of an Unrolled Linked List in C#?
- Finding Hudson Log Files
- Forward to a payment-gateway together with POST data using cURL (or any other PHP server side solution)
- WCF in Winforms app - is it always single-threaded?

随机阅读：

**推荐内容**-

**热点内容**