Alireza
Alireza

Reputation: 311

exchange axis of an "ezplot"

how can i change the horizontal and vertical axis of an ezplot of a symbolic equation?

for example an implicit equation of lambda & beta. how MATLAB can understand what i want to be for x axis and what for y axis??


but i have a main expression of beta not a function and is so long. because it is made of some parameters that they themselves are made of some expressions too. how can i convert it to a function? i mean, can i use the name of the main expression to make a function?

for example if: n1,n2,m,a=const. u=sqrt(n2-beta^2); w=sqrt(beta^2-n1); a=tan(u)/w+tanh(w)/u; b=tanh(u)/w; f=(a+b)cos(au+mpi)+a-bsin(au+mpi); is the main expression.

Upvotes: 1

Views: 4927

Answers (1)

Amro
Amro

Reputation: 124573

You can use a function handle, and flip the order (x,y) vs (y,x):

figure(1), ezplot( @(x,y) sqrt(x.^2 + y.^2 - 1), [-2 2 -4 4] )
figure(2), ezplot( @(y,x) sqrt(x.^2 + y.^2 - 1), [-2 2 -4 4] )

Let me give you another easier solution. Just plot your your function the usual way, then use:

view([90 -90])

to rotate the axes (x-axis becomes y-axis and vice versa)

Upvotes: 3

Related Questions