Hi Andrew,
Why not collect the line and the curve in two separate vectors? You should also collect the corresponding depth info so that you will say:
plot(hLine,linePoints)
hold on
plot(hCurve,curvePoints,'r')
or something like that.
Best.
"Andrew Cross" <butross@hotmail.com> wrote in message <hnbndh$2uk$1@fred.mathworks.com>...
> Hi,
>
> I'm fairly new to Matlab and am having some problems with plotting functions.
> I've got two functions that I want to plot. One is a line, the other is a negative exponential curve. Both functions are calculated with depth simultaneously, but I only want to display one of the functions at each given depth (i.e. when the line function has a value less than that of the curve, I want it to plot the line, but when the curve becomes less than the line, I want to only plot the curve).
>
> If I do this within the for loop, it only plots the points at which depth is calculated (h = 0:0.1:40)  is there any way to join these points to form a solid line? The code is:
>
> if (var2(:,n) < var3(:,n))
> plot(var2(n),h(n),'linewidth',1);
> legend('Straight line');
> else
> plot(var3(n),h(n),'r','linewidth',1);
> legend('Curve');
> end
>
> Otherwise, if I place the plot function outside the for loop, the 'if' function doesn't work and only plots whichever function is least at the maximum depth.
>
> Any help really would be very much appreciated!
>
> Cheers,
>
> Andrew
