Search code examples
matlabplotgeometry-surface

3D Surface plot misplaced axis


The code is:

subplot(1,3,3)
h=surf(ReflMatrix)
set(h, 'edgecolor','none')
colormap winter %Other colourmaps: Winter,Cool
hold on;
ylabel('frequency (Hz)');
xlabel('angle of incidence (degrees)'); 
alpha(.5) %transparency

The ReflMatrix is 401x90. The values of y range from 0 to 90, which is good because y is angle measured in degrees . The values of x (frequency) range from 0 to 401 because my bandwidth is 401 frequencies but I would like the same graph with values ranging from 300 to 700 (instead of starting from frequency 0 to start from frequency 300).


Solution

  • In surf you can specify your x and y. In your case, define your frequency by

    y = linspace(300,700,401);
    

    and the phase by

    x = linspace(0,90,91); 
    

    Are you sure with the size of ReflMatrix, since frequencies from 0 to 90 are 91 points rather than 90. Then set your x and y parameters according to

    [X,Y] = meshgrid(x,y);
    h = surf(X,Y,ReflMatrix);
    

    EDIT:

    You can set the limits of the axes accordingly by

    xlim([0 90]);
    ylim([300 700]);
    zlim([min(min(ReflMatrix)) max(max(ReflMatrix))]);