Error using mesh (line 71) Z must be a matrix, not a scalar or vector.

조회 수: 8 (최근 30일)
FARHA KHAN
FARHA KHAN 2022년 12월 15일
댓글: FARHA KHAN 2022년 12월 19일
I am trying to get mesh plot
a=eletxt(:,1);
b=eletxt(:,2);
c=ele(:,5);
a1=table2array(theta(1:5:end,:));
b1=table2array(phi(1:5:end,:));
c1=table2array(phase(1:5:end,:));
u=mesh( theta1,phi1,phase1)
I am getting error saying
Error using mesh (line 71)
Z must be a matrix, not a scalar or vector.
Error in Untitled_phase (line 10)
u=mesh( theta1,phi1,phase1)
  댓글 수: 3
FARHA KHAN
FARHA KHAN 2022년 12월 15일
Oh sorry I have edited that line I think it's not copied properly It's not theta1 phi1 and phase 1 It's a1,b1,c1
FARHA KHAN
FARHA KHAN 2022년 12월 15일
I have rectified this error Thank you

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

답변 (1개)

Harshit Saini
Harshit Saini 2022년 12월 19일
As stated in the error, the “mesh” function takes in an input as a matrix. Mesh considers the row and column indices as the x-coordinate and the y-coordinate for the plot.
From the provided code snippet, it seems the parameters inside the “mesh” function are vectors, and not a matrix. I would suggest reshaping the variable accordingly using the following function,
A = 1:10;
B = reshape(A, [5,2])
You can read more about reshaping the arrays here,
  댓글 수: 1
FARHA KHAN
FARHA KHAN 2022년 12월 19일
Thank you for the response
Sir Its a matrix only sir
I have checked it with command ismatrix()

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

카테고리

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

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by