How do I plot 2 surf plots in different figures
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Luis Landa Pulgar
el 9 de Abr. de 2021
Editada: Cris LaPierre
el 9 de Abr. de 2021
Hi,
I am trying to plot 2 different surf plots, however when I plot the second one it overwrites the first one. I need them both to be outputed as two separate figures. I have tried to use the figure command but it does not work, it keeps overwriting. Also, if use figure(1) and figure(2), it says that for figure(2) "Index exceeds the number of array elements (1)."
Here is what I have:
x = -2:0.1:2;
y = -2:0.1:2;
[x,y] = meshgrid(x, y);
U = (x.^2+y.^2).^0.5;
V = 4*del2(U);
figure
surf(x,y,U)
xlabel('x');ylabel('y');
title('Function Plot z = (x^2 + y^2)^0.5');
figure
surf(x,y,V)
figure;
xlabel('x');ylabel('y');
title('Laplacian Plot')
0 comentarios
Respuesta aceptada
Cris LaPierre
el 9 de Abr. de 2021
Editada: Cris LaPierre
el 9 de Abr. de 2021
The code you have shared appears to work fine. You do have an extra figure; command that you don't need (after the second surf command).
x = -2:0.1:2;
y = -2:0.1:2;
[x,y] = meshgrid(x, y);
U = (x.^2+y.^2).^0.5;
V = 4*del2(U);
figure
surf(x,y,U)
xlabel('x');ylabel('y');
title('Function Plot z = (x^2 + y^2)^0.5');
figure
surf(x,y,V)
xlabel('x');ylabel('y');
title('Laplacian Plot')
The error about index exceeding array elements suggests that you have probably accidentally created a variable figure that has now taken precedence over MATLAB's function figure. Clear your workspace and try again. If it continues to happen, inspect the rest of your code for anywhere where you assign figure a value.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

