How to further define a function?
1 view (last 30 days)
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 ****
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;
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;
numPts = 50;
x = linspace(0,obj.D,numPts);
y = zeros(1,numPts);
y(i) = obj.CreateFullSection(x(i));
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.