From: striker on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hscq8g$scb$1(a)canopus.cc.umanitoba.ca>...
> striker wrote:
>
> > I have plotted a straigh cylinder in matrix form using repmat and surf
> > commands.now i want to use the same procedure for curved cylinder.
>
> repmat is fine when you need to duplicate data, but since you want the data to
> be different for every slice, you probably do not have much need for repmat().
>
> Can the cylinder be solid? That is easier to program as a matrix than if you
> just want the outer surface.
>
> Is there a formula for the radius given Z? If so, then it is probably a matter
> of starting with a 3D matrix of nan, and then using ndgrid() and logical
> indexing to set the values of the matrix.

No I have to work on the surface and i dont have any formula for radius. can u help me for it as well... the idea is that the curved cylinder should have greater radius at top and bottom and small radius in the center of the curved cylinder
From: Walter Roberson on
striker wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <hscq8g$scb$1(a)canopus.cc.umanitoba.ca>...
>> striker wrote:
>>
>> > I have plotted a straigh cylinder in matrix form using repmat and
>> surf > commands.now i want to use the same procedure for curved cylinder.
>>
>> repmat is fine when you need to duplicate data, but since you want the
>> data to be different for every slice, you probably do not have much
>> need for repmat().
>>
>> Can the cylinder be solid? That is easier to program as a matrix than
>> if you just want the outer surface.
>>
>> Is there a formula for the radius given Z? If so, then it is probably
>> a matter of starting with a 3D matrix of nan, and then using ndgrid()
>> and logical indexing to set the values of the matrix.
> no I want the surface only. I dont have any formula for radius. the idea
> is that the radius should be greater on top and bottom and smaller at
> the middle.

If you show your existing code, then we can indicate how to modify it to
be most close to what you are doing now.
From: striker on
% % Sample values
h = 10;ri = 1;ra = 1;
% % Create constant vectors
tht = linspace(0,2*pi,100);
z=linspace(-5,5,20);

% % Create inner cylinder
xi = repmat(ri*cos(tht),20,1);
yi = repmat(ri*sin(tht),20,1);
zi = repmat(z',1,100);

% % Create outer cylinder
xa = repmat(ra*cos(tht),20,1);
ya = repmat(ra*sin(tht),20,1);
za = zi;

surf(xa,ya,za);axis image
title('original 3D-object')

% % Now, if you want to close the ends:

x = [xi; flipud(xa); xi(1,:)];
y = [yi; flipud(ya); yi(1,:)];
z = [zi; flipud(za); zi(1,:)];
figure
surf(x,y,z)

this is the code for the normal cylinder on which I am working. I need a curved cylinder with the same idea so that my calculation which are based (working fine) on the normal cylinder also work on the curved cylinder.
Walter Roberson <roberson(a)hushmail.com> wrote in message <gxGGn.6845$wV2.2803(a)newsfe23.iad>...
> striker wrote:
> > Walter Roberson <roberson(a)hushmail.com> wrote in message
> > <hscq8g$scb$1(a)canopus.cc.umanitoba.ca>...
> >> striker wrote:
> >>
> >> > I have plotted a straigh cylinder in matrix form using repmat and
> >> surf > commands.now i want to use the same procedure for curved cylinder.
> >>
> >> repmat is fine when you need to duplicate data, but since you want the
> >> data to be different for every slice, you probably do not have much
> >> need for repmat().
> >>
> >> Can the cylinder be solid? That is easier to program as a matrix than
> >> if you just want the outer surface.
> >>
> >> Is there a formula for the radius given Z? If so, then it is probably
> >> a matter of starting with a 3D matrix of nan, and then using ndgrid()
> >> and logical indexing to set the values of the matrix.
> > no I want the surface only. I dont have any formula for radius. the idea
> > is that the radius should be greater on top and bottom and smaller at
> > the middle.
>
> If you show your existing code, then we can indicate how to modify it to
> be most close to what you are doing now.
From: striker on
"striker " <friend_019(a)hotmail.com> wrote in message <hsgcjs$c0n$1(a)fred.mathworks.com>...
> % % Sample values
> h = 10;ri = 1;ra = 1;
> % % Create constant vectors
> tht = linspace(0,2*pi,100);
> z=linspace(-5,5,20);
>
> % % Create inner cylinder
> xi = repmat(ri*cos(tht),20,1);
> yi = repmat(ri*sin(tht),20,1);
> zi = repmat(z',1,100);
>
> % % Create outer cylinder
> xa = repmat(ra*cos(tht),20,1);
> ya = repmat(ra*sin(tht),20,1);
> za = zi;
>
> surf(xa,ya,za);axis image
> title('original 3D-object')
>
> % % Now, if you want to close the ends:
>
> x = [xi; flipud(xa); xi(1,:)];
> y = [yi; flipud(ya); yi(1,:)];
> z = [zi; flipud(za); zi(1,:)];
> figure
> surf(x,y,z)
>
> this is the code for the normal cylinder on which I am working. I need a curved cylinder with the same idea so that my calculation which are based (working fine) on the normal cylinder also work on the curved cylinder.
> Walter Roberson <roberson(a)hushmail.com> wrote in message <gxGGn.6845$wV2.2803(a)newsfe23.iad>...
> > striker wrote:
> > > Walter Roberson <roberson(a)hushmail.com> wrote in message
> > > <hscq8g$scb$1(a)canopus.cc.umanitoba.ca>...
> > >> striker wrote:
> > >>
> > >> > I have plotted a straigh cylinder in matrix form using repmat and
> > >> surf > commands.now i want to use the same procedure for curved cylinder.
> > >>
> > >> repmat is fine when you need to duplicate data, but since you want the
> > >> data to be different for every slice, you probably do not have much
> > >> need for repmat().
> > >>
> > >> Can the cylinder be solid? That is easier to program as a matrix than
> > >> if you just want the outer surface.
> > >>
> > >> Is there a formula for the radius given Z? If so, then it is probably
> > >> a matter of starting with a 3D matrix of nan, and then using ndgrid()
> > >> and logical indexing to set the values of the matrix.
> > > no I want the surface only. I dont have any formula for radius. the idea
> > > is that the radius should be greater on top and bottom and smaller at
> > > the middle.
> >
> > If you show your existing code, then we can indicate how to modify it to
> > be most close to what you are doing now.

h = 10;ri = 1;ra = 1;
% % Create constant vectors
tht = linspace(0,2*pi,100);
z=linspace(-5,5,20);

% % Create inner cylinder
xi = repmat(ri*cos(tht),20,1);
yi = repmat(ri*sin(tht),20,1);
zi = repmat(z',1,100);

% % Create outer cylinder
xa = repmat(ra*cos(tht),20,1);
ya = repmat(ra*sin(tht),20,1);
za = zi;

surf(xa,ya,za);axis image
title('original 3D-object')

% % Now, if you want to close the ends:

x = [xi; flipud(xa); xi(1,:)];
y = [yi; flipud(ya); yi(1,:)];
z = [zi; flipud(za); zi(1,:)];
figure
surf(x,y,z)

this is the code for the normal cylinder on which I am working. I need a curved cylinder with the same idea so that my calculation which are based (working fine) on the normal cylinder also work on the curved cylinder.
From: Walter Roberson on
striker wrote:

> this is the code for the normal cylinder on which I am working. I need a
> curved cylinder with the same idea so that my calculation which are
> based (working fine) on the normal cylinder also work on the curved
> cylinder.

Do you need the wall of the cylinder to be of constant thickness, or is
it acceptable for it to vary in thickness (e.g., becoming thinner when
the cylinder curves inward) ?