Prev: image to data conversion
Next: xpc shared interrupts
From: peter on 15 Feb 2010 08:40 Hi, Posted here a while ago, but no one answered so I will try to simplify what i meant. I have these line plots (x,y) and want to rotate these around the y-axis to create a volume/surface, or rather a 2d view from above, such as level curves. Is there a function in matlab that can make this happen?
From: Cokelid on 15 Feb 2010 09:16 > Posted here a while ago, but no one answered so I will try to simplify what i meant. I have these line plots (x,y) and want to rotate these around the y-axis to create a volume/surface, or rather a 2d view from above, such as level curves. > Is there a function in matlab that can make this happen? It should be pretty simple trigonometry to rotate the line around Y to produce a set of X,Y,Z vertices (or look up cylindrical-polar to Cartesian conversion if you can't be bothered). Once you have X,Y,Z it's just a bit of messing around with the mesh() or surf() functions (though I don't know about level curves). Justin
From: peter on 15 Feb 2010 09:37 Cokelid <cokelid(a)googlemail.com> wrote in message <6be24ab1-a48e-4cd3-ac23-538b2da8141e(a)t42g2000vbt.googlegroups.com>... > > Posted here a while ago, but no one answered so I will try to simplify what i meant. I have these line plots (x,y) and want to rotate these around the y-axis to create a volume/surface, or rather a 2d view from above, such as level curves. > > Is there a function in matlab that can make this happen? > > It should be pretty simple trigonometry to rotate the line around Y to > produce a set of X,Y,Z vertices (or look up cylindrical-polar to > Cartesian conversion if you can't be bothered). Once you have X,Y,Z > it's just a bit of messing around with the mesh() or surf() functions > (though I don't know about level curves). > > Justin Yeah, what I want in the end is a matrix that can be used for the surf() function. To just rotate it wouldnt be any problems with trigonometric functions, but to fit it to matrix elements requires interpolation and such?
From: Lorenzo Guerrasio on 15 Feb 2010 10:30 "peter " <petzh912(a)student.liu.se> wrote in message <hlbm6f$b1p$1(a)fred.mathworks.com>... > Cokelid <cokelid(a)googlemail.com> wrote in message <6be24ab1-a48e-4cd3-ac23-538b2da8141e(a)t42g2000vbt.googlegroups.com>... > > > Posted here a while ago, but no one answered so I will try to simplify what i meant. I have these line plots (x,y) and want to rotate these around the y-axis to create a volume/surface, or rather a 2d view from above, such as level curves. > > > Is there a function in matlab that can make this happen? > > > > It should be pretty simple trigonometry to rotate the line around Y to > > produce a set of X,Y,Z vertices (or look up cylindrical-polar to > > Cartesian conversion if you can't be bothered). Once you have X,Y,Z > > it's just a bit of messing around with the mesh() or surf() functions > > (though I don't know about level curves). > > > > Justin > > Yeah, what I want in the end is a matrix that can be used for the surf() function. To just rotate it wouldnt be any problems with trigonometric functions, but to fit it to matrix elements requires interpolation and such? I'm not sure I understood what you need: imagine you have the line y=mx+q you can compute the surface generate by rotation in x,yposition straighforward (I guess). [x,z]=meshgrid(-10:.1:10); ypos=-m/q+m.*(x.^2+z.^2); yneg=-m/q-m.*(x.^2+z.?2); figure,surf(x,z,ypos) hold on, surf(x,z,yneg)
From: peter on 16 Feb 2010 03:30
Thanks for your answer, when I tried your code it gives me someting like an exponential curve, also when I choose q=0 then you get division by zero. I have a vector with predefined values which I'm trying to rotate. My current solution is to calculate the distance from each matrix element to the center and then interpolate the appropriate value, for instance distance 20.5 then I make a linear interpolation between element 20 and 21 from my vector. There should exist an easier way...? |