필터 지우기
필터 지우기

How to make a surface plot for two vectors?

조회 수: 13 (최근 30일)
stelios loizidis
stelios loizidis 2023년 6월 23일
답변: Walter Roberson 2023년 6월 23일
Hello,
I have two row-vectors, A (1X8000) and B (1X8000). What I want is their surface plot. I tried the commands below:
surf(A,B)
colorbar
But it does not work. The following error occurs.
Error using surf
Z must be a matrix, not a scalar or vector.
How can the surface plot of the two variables be made? Your help is valuable.
  댓글 수: 1
Nitya Patel
Nitya Patel 2023년 6월 23일
Depending on what your data represents, there could be different ways to do it. One of the ways possible is this:
M = [A; B]';
surf(M);

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 6월 23일
You cannot do that. surf() and surface() can only handle 2D grids of data. For surf() and surface() the X and Y data do not need to be rectangular or even rectilinear -- you can even use them to plot a hemi-sphere for example -- but they do need to be 2D.
If you had three vectors instead of two vectors, you could consider using tools such as griddata or scatteredInterpolant

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by