1

I have 4 row vectors x, y, z and s, all of them have equal sizes 1*size. x, y, z should be the three Cartesian corodinate axes and s should be represented by colors (I want figure like below image). The statement Surf does not accept row vectors. I have read several stackoverflow post, but I could not find the answer. How can I plot such a figure? I really appreciate any help you can provide.

Mr. Nobody
  • 327
  • 2
  • 8
  • 21

2 Answers2

1

You can try with this example of a 3D cube for a 3D meshgrid and it plots the "temperature".

example

L = 1;
dx = 0.25;
dy = dx;
dz = dy;
Nx = L/dx;   Ny = Nx;    Nz = Ny;
x = dx/2:dx:L-dx/2;
y = x;       z = y;
[xx, yy, zz] = meshgrid(x,y,z);
theta = NaN(size(zz));

for jj=1:4;
    for ii=1:4
        for kk=1:4
            theta(jj,ii,kk) = 273.15 + 5.*random('normal', 0, 1)
        end
    end
end

clf
isosurface(xx, yy, zz, theta)
colorbar
colormap jet
[fe, ve, ce] = isocaps(x, y, z, theta, 10);
p2 = patch('Faces', fe, 'Vertices', ve, 'FaceVertexCData', ce);
p2.FaceColor = 'interp';
p2.EdgeColor = 'none' ;
grid on
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
title('Temperatures');
set(gca, 'clim', [273.15 273.15+5])
set(get(colorbar, 'title'), 'string', 'K', 'FontW', 'bold', 'fontname', 'Times New Roman', 'fontsize', 14);
view(3)
Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
0

I can't test it because you didn't provide any data, but you could try:

trisurf(x,y,z,s)

If that doesn't work then try:

DT = delaunayTriangulation(x,y,z);
tetramesh(DT,s);
EBH
  • 10,350
  • 3
  • 34
  • 59
KiW
  • 593
  • 3
  • 20
  • Thank you @KiW. First statement lead to this warning: `Values in patch Faces must be in [1 : rows(Vertices)] - not rendering` and second code lead to an error: `Error using tetramesh (line 103) The number of colors should equal the number of tetrahedra.` – Mr. Nobody Jul 06 '16 at 09:14
  • do you have some sample data ? – KiW Jul 06 '16 at 09:17