필터 지우기
필터 지우기

What is wrong with my inputs for 'scatter3'?

조회 수: 13 (최근 30일)
Victoria K
Victoria K 2022년 4월 8일
댓글: Voss 2022년 4월 8일
I need help using 'scatter3' to make a 3d dot plot.
My inputs are:
x = 20000 x 1 datetime
y= 1 x 9 double
z = 9 x 20000 double
I'm trying scatter3(x,y,z). I keep getting an error saying: 'X, Y, Z, and size arguments must be vectors of the same length, matrices of the same size, or a mix of vectors and matrices where the length of the vectors matches either the number of rows or columns of the matrices."
I don't understand why I'm getting problems? Both the x and y lengths matches the row/column lengths of Z.
It works when I use surf, but not scatter3.
Thanks in advance!

채택된 답변

Voss
Voss 2022년 4월 8일
% x, y, z similar to yours:
x = datetime(1e4*rand(200,1)+7.2e5,'ConvertFrom','datenum');
y = rand(1,9);
z = rand(9,200);
% make matrices X and Y by repeating elements
% of x and y in a particular manner:
[X,Y] = meshgrid(x,y);
% use scatter3 with 3 matrices of the same size:
scatter3(X,Y,z)
  댓글 수: 2
Victoria K
Victoria K 2022년 4월 8일
Thanks! Tried that and it worked.
Voss
Voss 2022년 4월 8일
You're welcome!

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

추가 답변 (0개)

카테고리

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