0

To preface I am not familiar with Matlab, sorry for any obvious or stupid mistakes.

ThesisBluePhase3Data1360 has three columns of 1210 values. I look at my workspace and can see that x is a 1210x1 double matrix.

Despite this, running the code below returns Error using surf (line 82) Z must be a matrix, not a scalar or vector. %Why does this happen?

Error in Untitled (line 9)
surf(x,y,z1,'EdgeColor','none')

Note: I've commented the reshape values because I was getting this error and I see why the matrices actually need to be resized (please correct me if I'm wrong). My intent is to use surf2stl once I understand these issues.

Code in question

x = ThesisBluephase3Ddata1360.x;
y = ThesisBluephase3Ddata1360.y;
z = ThesisBluephase3Ddata1360.z;
%x = reshape(x,39,31);
%y = reshape(y,39,31);
%z = reshape(z,39,31);
z1=(5.4/4.83).*z;
figure(3);  
surf(x,y,z1,'EdgeColor','none')
hold on
contour3(x,y,z1,0,'k')
hold off
xlabel('x') 
ylabel('y')
zlim([0 2000])
zlabel('Irradiance (mW/cm^2)')
title('Bluephase');
colorbar
caxis([0 2000])
rotate3d on;

Thank you for your time!

  • you need to have a 3 matrices, each describing x y and z location on a mesh. The documentation is quite clear I think – Ander Biguri Mar 20 '18 at 23:11
  • You should reshape your matrix to use `surf`. The matrix Z from `(X, Y, Z)` must be a 3D array. – rbcvl Mar 21 '18 at 10:38

0 Answers0