Sunday, March 20, 2011

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??

From stackoverflow
  • 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)

  • 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(a*u+m*pi)+a-b*sin(a*u+m*pi); is the main expression.

    Amro : your function boils down to being a function of one variable *beta*, and you can write it as one expression if you want. Also I don't see a mention of *lambda* from your original question..
    Amro : tell you what, why dont you post the actual MATLAB code that you currently use to plot the function?
    gnovice : Also, *edit your question* and add the additional information instead of posting a new answer. You should also delete this answer, since it isn't an actual "answer".
    Alireza : suppose that "a" is an expression of lambda. if i want to convert "f" to a function(using it in an algorithm to find zeros, later), how can i do that without writing net explicit form?

0 comments:

Post a Comment