3D or surface plot

1 回表示 (過去 30 日間)
MOHD UWAIS
MOHD UWAIS 2021 年 2 月 26 日
コメント済み: MOHD UWAIS 2021 年 2 月 26 日
Hi,
Please look at my problem. I have a 'A' as dependent variable of two variables B and L. How I could plot in 3D or surface plot of these three variables. If I have two 'for loop' like (for example),
for B=-10:10;
for L=-10:10;
A=B+L^2;
end
end

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 2 月 26 日
If you are going to build A using nested for loops, then you need to capture the result of each loop. You are currently overwritting A each time. See this page for more and examples.
Of course, with MATLAB, you don't need the for loops. The main thing you need to create a surface is for A to be a matrix. Take advantage of MATLAB's array capabilities.
B=-10:10;
L=-10:10;
% Transpose B to take advantage of implicit expansion to create the matrix.
A=B'+L.^2;
surf(A)
  1 件のコメント
MOHD UWAIS
MOHD UWAIS 2021 年 2 月 26 日
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by