Error using mesh (line 71) Z must be a matrix, not a scalar or vector.
Show older comments
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 Comments
Jan
on 15 Dec 2022
The error message is clear. You do not show, how theta1, phi1 and phase1 are created. Therefore there is no chance to know, why phase1 is not a matrix.
FARHA KHAN
on 15 Dec 2022
FARHA KHAN
on 15 Dec 2022
Answers (1)
Harshit Saini
on 19 Dec 2022
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 Comment
FARHA KHAN
on 19 Dec 2022
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!