How can I improve the surface representation? I did another plot for another set of simulation results which came out better, Any way to control the surface grid resolution. I do not need to use plot3 but being able to plot to surfaces in one plot based on columns 3 and 4 data from the same file is a must
The simulated data for this case were fairly smooth while the data file for the first figure involves a steep change
Explain what “did not work” means. Did it give an error? If so paste it.
Also look at help surf. Your x and y should be vectors and z should be a matrix of appropriate size. From your figures above you look like you have x and y values on a grid so you can try giving them without repetitions to surf.
@Bjoern, you’re repeating the same error. Look very carefully at help surf. Your z needs to be a matrix not a vector. Its order needs to reflect the length of x and the length of y. At the very least, you’ll need to reshape the Z you have into that matrix shape before you call surf. Make sure that each element of Z corresponds to the correct x and the correct y.
Sorry for missing that point, which obviously is important
I cannot easily rearrange z into a matrix
I simply have 3 rows in which x and z are rows 1 and 2 and the same for both plots and the row3 on one surface and row4 on another surface
If you’re using plot3, the only way to reduce the step size is to sample more x and y points before plotting.
Let me offer this code. You should be able to adapt it to your needs hopefully. Observe the reshape statements before the call to surf:
[xx,yy] = meshgrid (0:0.1:10, 0:0.1:5);
xx = xx(:); # size 5151x1
yy = yy(:); # size 5151x1
z1 = 10*xx + 3*yy + 1;
z2 = 3*xx + 5*yy + 1;
# assume that the above has already been done by the time you load hyd3d
# so xx == hyd3d(:,1)
# and yy == hyd3d(:,2)
# and z1 and z2 are hyd3d(:,3) and hyd3d(:,4) respectively
x = unique(xx); # length == 101
y = unique(yy); # length == 51
z1 = reshape (z1, numel(y), numel(x)); # size 51x101
z2 = reshape (z2, numel(y), numel(x)); # size 51x101
surf (x, y, z1);
surf (x, y, z2);
If you get an error on the reshape statements, then right away you will know that the size of your z vectors are not compatible with the number of x and y points. But your figures above really do look like x and y were generated on a grid, so hopefully this works for you.