How do I plot 2 surf plots in different figures
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Cris LaPierre
2021 年 4 月 9 日
編集済み: Cris LaPierre
2021 年 4 月 9 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

