Can t plot the image bellow and flip the y axis

6 views (last 30 days)
Hello everyone,
i enter an excel table in matlab with the values of x,y and z but i couldn t plot the 3D Image :(
this is my code:
num = xlsread('file.xl') ;
X = num(:,1) ;
Y = num(:,2) ;
[x,y]=meshgrid(fliplr(Y),X)
Z = num(:,3) ;
figure
plot3(x,y,Z);
%set(gca,'Ydir','reverse')
I have to flip the y axis but i couldn t, nothing happens with fliplr. i tried set(gca,'Ydir','reverse') but it didn t worked.
bellow is the attached image of the plot that i have to obtain.
has anyone an idea please ?
thanks for helping me
Best regards
  1 Comment
DGM
DGM on 2 Dec 2021
Edited: DGM on 2 Dec 2021
Attach the data so that it can be determined how the data is arranged. It doesn't make sense to be using plot3() to replicate the indicated surface plot, but if the data is scattered or striped, then extra work is needed. Using surf() requires Z to be 2D, which it's not. Addressing that requires an understanding of why it's a vector instead of a matrix.
The function fliplr() flips an array along dim2. Since all your vectors are column vectors, flipping on dim2 does nothing to it. You're also using the Y vector to define the X mesh and vice-versa in the call to meshgrid().
You'll need to define 'flip the y axis". Flipped about what point? If zero, then what's wrong with Y = -Y? If some other point, where? Is it just that data that needs to be flipped, or does the actual axis need to be reversed?

Sign in to comment.

Answers (0)

Categories

Find more on Line Plots 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!