Plot 4D....different contours

1 次查看(过去 30 天)
Hello,
I have a set of data with 3 variables and the values of the signal.
All the three variables change in [-2,2] and the output values Y go from 800 to 1400. The values of (x1,x2,x3) are here below written:
0 -1,73205161513813 -1,73210161662818
0 -1,73205161513813 0
0 -1,73205161513813 1,73210161662818
0 0 -1,73210161662818
0 0 0
0 0 1,73210161662818
0 1,73205161513813 -1,73210161662818
0 1,73205161513813 0
0 1,73205161513813 1,73210161662818
1,73210161662818 -1,73205161513813 -1,73210161662818
1,73210161662818 -1,73205161513813 0
1,73210161662818 -1,73205161513813 1,73210161662818
1,73210161662818 0 -1,73210161662818
1,73210161662818 0 0
1,73210161662818 0 1,73210161662818
1,73210161662818 1,73205161513813 -1,73210161662818
1,73210161662818 1,73205161513813 0
1,73210161662818 1,73205161513813 1,73210161662818
-1,73210161662818 -1,73205161513813 -1,73210161662818
-1,73210161662818 -1,73205161513813 0
-1,73210161662818 -1,73205161513813 1,73210161662818
-1,73210161662818 0 -1,73210161662818
-1,73210161662818 0 0
-1,73210161662818 0 1,73210161662818
-1,73210161662818 1,73205161513813 -1,73210161662818
-1,73210161662818 1,73205161513813 0
-1,73210161662818 1,73205161513813 1,73210161662818
%Discretisation
x1fit = min(x1):.1:max(x1);
x2fit = min(x2):.1:max(x2);
x3fit = min(x3):.1:max(x3);
%Create the mesh
[X1FIT,X2FIT,X3FIT] = meshgrid(x1fit,x2fit,x3fit);
%Evaluate the Y at the different locations
b=[898.619500324491 -49.6569643950741 0.957244154182521 -0.474633267533362 0.109261217410249 0.128653191020651
0.109267525885722 0.0654684323159314 0.155519747861591 -0.265812849175710]
YFIT = b(1)+b(2)*X1FIT+b(3)*X2FIT+b(4)*X3FIT+b(5)*(X1FIT.^2-1)+b(6)*X1FIT.*X2FIT+b(7)*(X2FIT.^2-1)+b(8)*X2FIT.*X3FIT+b(9)*(X3FIT.^2-1)+b(10)*X3FIT.*X1FIT;
mesh(X1FIT,X2FIT,X3FIT,YFIT)
% I run the following program, but it gives this problem:
??? CData must be an M-by-N matrix or M-by-N-by-3 array
Error in ==> graph3d.surfaceplot.surfaceplot>localConstructor at 136
h = graph3d.surfaceplot(argin{:});
Error in ==> graph3d.surfaceplot.surfaceplot at 7
h = localConstructor(varargin{:});
Error in ==> mesh at 172
hh = graph3d.surfaceplot(x,y,z,c,'FaceColor',fc,'EdgeColor','flat', ...
Error in ==> RegressioneLineare at 42 mesh(X1FIT,X2FIT,X3FIT,YFIT)
I would like to see the surface (x1,x2,x3) coloured with the Y or contours of Y .... I guess that both tasks should be straightforward, but I am not succeding, please suggest me how to solve this issue.
Thanks a lot Antonio

采纳的回答

LY Cao
LY Cao 2011-11-7
do you mean this:
close all
clear,clc
x=[0 -1.73205161513813 -1.73210161662818
0 -1.73205161513813 0
0 -1.73205161513813 1.73210161662818
0 0 -1.73210161662818
0 0 0
0 0 1.73210161662818
0 1.73205161513813 -1.73210161662818
0 1.73205161513813 0
0 1.73205161513813 1.73210161662818
1.73210161662818 -1.73205161513813 -1.73210161662818
1.73210161662818 -1.73205161513813 0
1.73210161662818 -1.73205161513813 1.73210161662818
1.73210161662818 0 -1.73210161662818
1.73210161662818 0 0
1.73210161662818 0 1.73210161662818
1.73210161662818 1.73205161513813 -1.73210161662818
1.73210161662818 1.73205161513813 0
1.73210161662818 1.73205161513813 1.73210161662818
-1.73210161662818 -1.73205161513813 -1.73210161662818
-1.73210161662818 -1.73205161513813 0
-1.73210161662818 -1.73205161513813 1.73210161662818
-1.73210161662818 0 -1.73210161662818
-1.73210161662818 0 0
-1.73210161662818 0 1.73210161662818
-1.73210161662818 1.73205161513813 -1.73210161662818
-1.73210161662818 1.73205161513813 0
-1.73210161662818 1.73205161513813 1.73210161662818];
%Discretisation
[x1,x2,x3]=deal(x(:,1),x(:,2),x(:,3));
x1fit = min(x1):.1:max(x1);
x2fit = min(x2):.1:max(x2);
x3fit = min(x3):.1:max(x3);
%Create the mesh
[X1FIT,X2FIT] = meshgrid(x1fit,x2fit);
X3FIT=griddata(x1fit,x2fit,x3fit,X1FIT,X2FIT,'v4');
%Evaluate the Y at the different locations
b=[898.619500324491 -49.6569643950741 0.957244154182521 -0.474633267533362 0.109261217410249 0.128653191020651 0.109267525885722 0.0654684323159314 0.155519747861591 -0.265812849175710];
YFIT = b(1)+b(2)*X1FIT+b(3)*X2FIT+b(4)*X3FIT+b(5)*(X1FIT.^2-1)+b(6)*X1FIT.*X2FIT+b(7)*(X2FIT.^2-1)+b(8)*X2FIT.*X3FIT+b(9)*(X3FIT.^2-1)+b(10)*X3FIT.*X1FIT;
surf(X1FIT,X2FIT,X3FIT,YFIT)
  1 个评论
mortain Antonio
mortain Antonio 2011-11-7
So I had the use the command surf! Thanks a lot!
If I have more than one value of b (hence different YFIT) is it possible to create something like a movie which show how the YFIT change?
Thanks a lot again
Anonio

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by