make a surface plot without knowing the x value in matlab

To make a surface plot in MATLAB without knowing the x value, you can use the meshgrid function to create a grid of x-y values, and then use the surf or mesh function to create the surface plot.

Here's an example code snippet that generates a surface plot without knowing the x-value:

% Generate grid of x-y values
[y, z] = meshgrid(linspace(-1,1,101),linspace(-1,1,101));

% Define function to plot (in this case, a simple example)
f = @(y, z) y.^2 + z.^2;

% Plot surface
surf(y, z, f(y,z));
colormap(jet); % Set colormap
xlabel('y'); ylabel('z'); zlabel('f(y,z)'); % Set axis labels
301 chars
11 lines

This code will generate a surface plot of the function f(y,z) = y^2 + z^2. The meshgrid function creates a grid of 101 x-y values between -1 and 1, and the surf function uses those values to create the surface plot of the function.

Note that you will need to define your own function to plot, based on your data and requirements. Also note that the grid points can be adjusted using different parameters in the meshgrid function call, depending on your specific needs.

related categories

gistlibby LogSnag