Getting error in the surfc plotting

7 views (last 30 days)
Tn = 100;
ns = 30;
alpha = 0
beta = 0
gama = 0
phi1 = linspace(-Tn,Tn,ns);
phi2 = linspace(-Tn,Tn,ns);
phi3 = linspace(-Tn,Tn,ns);
%Phase Angle Mesh-Grid
[phi_1,phi_2,phi_3] = meshgrid(phi1,phi2,phi3);
phi_12 = phi_2 - phi_1;
phi_21 = phi_1 - phi_2;
phi_13 = phi_3 - phi_1;
phi_31 = phi_1 - phi_3;
phi_23 = phi_3 - phi_2;
phi_32 = phi_2 - phi_3;
k11 = 917.3770;
k22 = 917.3770;
k33 = 917.3770;
k12 = 458.6885;
k13 = 458.6885;
k23 = 458.6885;
X = -(k12.*cos(alpha*pi*n/360).*cos(beta*pi*n/360).*sin(phi_12*pi*n/180))-(k13.*cos(alpha*pi*n/360).*cos(gama*pi*n/360).*sin(phi_13*pi*n/180))
Y = -(k12.*cos(alpha*pi*n/360).*cos(beta*pi*n/360).*sin(phi_21*pi*n/180))+(k23.*cos(beta*pi*n/360).*cos(gama*pi*n/360).*sin(phi_23*pi*n/180))
Z = -(k13.*cos(alpha*pi*n/360).*cos(gama*pi*n/360).*sin(phi_31*pi*n/180))+(k23.*cos(beta*pi*n/360).*cos(gama*pi*n/360).*sin(phi_32*pi*n/180))
figure(1);
surfc(phi_12,phi_13,X); colorbar;
figure(2);
surfc(phi_21,phi_23,Y); colorbar;
figure(3);
surfc(phi_31,phi_32,Z); colorbar;
Getting the following error:
Error using matlab.graphics.chart.primitive.Surface/set
Value must be a vector or 2D array of numeric type
Error in matlab.graphics.chart.internal.ctorHelper (line 8)
set(obj, pvpairs{:});
Error in matlab.graphics.chart.primitive.Surface
Error in surf (line 150)
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
Error in surfc (line 53)
hs = surf(cax, args{:});
Error in (line 68)
surfc(phi_12,phi_13,X); colorbar;
can anyone please help me fixing this error?
  6 Comments
Star Strider
Star Strider on 20 May 2018
Describe what you want to do.
Mukul
Mukul on 21 May 2018
Edited: Stephen23 on 21 May 2018
Just think in a very simple way: since alpha, beta and gama is zero, so the cos term is 1 and then the X Y and Z equation becomes
X=-k*sin(phi_12)-k*sin(phi_13)
Y=-k*sin(phi_21)+k*sin(phi_23)
Z=-k*sin(phi_31)+k*sin(phi_32)
Where
k=917.377
phi_12 = phi_2 - phi_1;
phi_21 = - phi_12;
phi_13 = phi_3 - phi_1;
phi_31 = - phi_13;
phi_23 = phi_3 - phi_2;
phi_32 = - phi_23;
Now I would like to do surfc plot of X in terms of phi_12, phi_13, Y in terms of phi_21 and phi_23 and Z in terms of phi_31 and phi_32 over the range of phi_1, phi_2 and phi_3 is -100 degree to 100 degree.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 20 May 2018
You need to use isosurface() instead of surfc()
  10 Comments
Walter Roberson
Walter Roberson on 20 Jun 2018
I don't think they should be the same. You are defining coordinates parametrically in different ways, and I see no reason why the shapes should all have the same angle when converted to one fixed set of coordinates.
I think that it is more likely that you can choose different coordinate basis that would make a different pair of the two look the same, and a third coordinate basis that make the remaining pair look the same -- each time there being one that looked different.
Using phi_12(:), phi_13(:) as a consistent arbitrary projection affects how the shapes look. Why should that pair of coordinates for the projection be any more right than, say, phi_23(:), phi_13(:) ?
Mukul
Mukul on 22 Jun 2018
Edited: Walter Roberson on 22 Jun 2018
Hi Walter thank you for your comments:
If I try in other ways without using the mesh grid function, I am getting these shapes where the three shapes looks almost same
Tn = pi/2;
ns = 30;
for i=1:40
for j=1:40
phi12 = pi/4*((i-20)/20);
phi23 = pi/4*((j-20)/20);
phi31 = -phi23 - phi12;
X(i,j)=sin(phi12)-sin(phi31);
Y(i,j)=-sin(phi12)+sin(phi23);
Z(i,j)=-sin(phi23)+sin(phi31);
end
end
a=1:40;
b=a;
aon2=10:30;
bon2=aon2;
figure(1);
surfc(a,b,X); colorbar;
figure(2);
surfc(a,-b,Y); colorbar;
figure(3);
surfc(-a,-b,Z); colorbar;
end
Do you think in the previous case, the mesh grid function causes the shapes not to be same?
Could you please comment on this?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!