MATLAB - Surf Plot data structure

后端 未结 2 1886
一向
一向 2021-01-15 01:31

I have done calculations with 2 different methods. For those calculations I have varied 2 parameters: x and y

In the end, I have calculated the % ERROR between both

相关标签:
2条回答
  • 2021-01-15 01:52

    create the grid for the first and second column and calculate Z using your formula. help meshgrid in MATLAB

    0 讨论(0)
  • 2021-01-15 02:06

    The surf function needs a grid of X,Y-values as input. Your data however is simply three vectors with some combinations, not a full grid. As described in the documentation, the meshgrid function is often helpful to create such grid matrices. Use the unique function to select all unique values in x and y and create matrices of all possible combinations:

    [X,Y] = meshgrid(unique(x),unique(y));
    

    To create a Z matrix which fits the [X,Y] grid, the griddata function is helpful:

    Z = griddata(x,y,z,X,Y);
    

    Now you can call surf with the grid matrices as input:

    surf(X,Y,Z);
    
    0 讨论(0)
提交回复
热议问题