MATLAB: Plotting a 3-D parametric curve (x,y,z) using different functions for x, y and z for different t values.

3-dparametric

What I've done here is split up a curve into sections and defined each of the sections through different functions.
I know how to plot a 3-D parametric curve using different t functions for x, y and z. So for my first section I have used the following:
>> t = linspace(0,pi); >> x = t; >> y = 3*t; >> z = 2*pi + 0*t; >> plot3(x,y,z)
This creates the first section of my curve. Now I want to change the function that defines y for the t values from pi to 2pi.
i.e. for t = linspace(pi,2*pi), I want to change y = 3*pi + sin(t-pi)
Can anyone show me how to do this? Also, eventually I want to plot all the different sections onto 1 set of axes.
On a side note, when I enter "y = 3*pi – 3(t-2*pi);", I am confronted with: | Error: Unbalanced or unexpected parenthesis or bracket. Why?
Thanks for any help

Best Answer

I rewrote Matt's example to make the idea more explicit; the first part in each line of the funy function selects the range and the second part implements the specific function for this interval.
funx = @(t) t;
funy = @(t) (t > 0 & t <= pi) .*3*t +...
(t > pi & t <= 2*pi).*(3*pi + sin(t - pi)) + ...
(t > 2*pi & t <= 3*pi).*(5*pi + cos(t - pi));
funz = @(t) 2*pi;
ezplot3(funx, funy, funz, [0, 3*pi])