How to further define a function?

1 view (last 30 days)
João on 31 Aug 2017
Edited: Walter Roberson on 31 Aug 2017
Hey guys, I'm writing a program and I have a section there where I need to define a function that looks like half a U letter (cutting it vertically). Now, what I have is the part where I define the curve and the part going up. It's like this:
function y = CreateFullSection(obj, x)
% Full Section curves
% ******* UNDER DEVELOPMENT ****
xFS=obj.sacXAtMaxArea;
R = ((obj.Hs(xFS)*obj.B/2 - obj.SAC(xFS))/(1.0 - pi/4.0))^0.5;
if ((x >= 0) && (x < R))
y = obj.B/2 - R + (2*R*x - x^2)^0.5;
elseif (x >= R)
y = obj.B/2;
end;
The value B is a constant and R is the curvature radius tht is calculated using functions that are done and working.
I'm plotting this using the following code:
function fig = PlotFullSect(obj, hull)
% Plot Full Sections
% [-1, +1]
fig = figure;
set(fig,'units','points','position',[0,0,600,300]);
numPts = 50;
x = linspace(0,obj.D,numPts);
y = zeros(1,numPts);
for i=1:numPts
y(i) = obj.CreateFullSection(x(i));
end;
plot(y,x);
title('Full Section');
plot(y,x) because the axes need to be switched, it is not a mistake. this gives me a line that starts at around 46 (= obj.B/2 - R) on the horizontal axis and then ha the radius and the straight part going up. And they seem to be correct.
what I need help with is to define this function to include the part where the fucntion = zero from 0 to 46.
Any ideas?
Thank you

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!