Re:



On Feb 12, 4:50 pm, "Ian Clarkson" <ian.clark...@xxxxxxxxxxxxxx>
wrote:
Muffin <aa...@xxxxxxxxxxx> wrote in message <68c7fd7b-439e-

4f0f-9f73-45d3e809c...@xxxxxxxxxxxxxxxxxxxxxxxxxxx>...> On Feb 12, 4:36 pm, rober...@xxxxxxxxxxxxxxxxxx (Walter
Roberson)
wrote:
In article <46b5fd6c-5318-4335-b6c6-

87469613b...@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,

Muffin <aa...@xxxxxxxxxxx> wrote:
I plotted data and then fitted it with a curve. Now I
want to find a
point between the data points where the area under
the curve equals
the area over the curve. This was working on another
computer last
night with an older version of Matlab but now the
error:
Subscript indices must either be real positive

integers or logicals.

keeps coming up.
Xdata = 0.1:.001:1.6;
plane = spline(X, Y, Xdata)

If you had a variable named 'spline', or if for some
reason the
routine named 'spline' could not be found, then Matlab
would think
you were trying to access a variable named 'spline'
with
indices that were not integers.

spline() does appear to be a part of basic matlab, at
least in
R2007a. I glanced around but could not find any
information as
to when it was introduced as an independant function
(as an option to interp1 it goes back to at least
Matlab 6.1)
--
"When a scientist is ahead of his times, it is often
through
misunderstanding of current, rather than intuition
of future truth.
In science there is never any error so gross that
it won't one day,
from some perspective, appear prophetic." -- Jean
Rostand

spline is a routine here. I used help spline. Do you
have any other
ideas to fit the data points then so I can use the
function fzero.
Apparently, that is where the error message: "Subscript
indices must
either be real positive integers or logicals." are

coming up

try putting a "clear spline" before you call the function,
just to make sure

Im pretty sure the spline isn't a problem:

%1.a)

%This plots the x-axis vs. the y-axis data points. I transposed it
into a
%column vector
X = [0.1:0.1:1.6]'
Y = [0.0, .1472, .34331, .5235, .6701, .7803, .8586, .9118, .9464, .
9683, .9817, .9897, .9943, .9969, .9983, 1.0]'

%Here, I fitted the data points using a cubicspline and plotted the
curve. Unfortunately, the fit
%option is on older versions of Matlab so it may not work on every
computer
%since I wrote the code in the Bard computer room where they were
older
%versions
Xdata = [0.1:.001:1.6]';
plane = spline(X, Y, Xdata)

plot(X, Y, 'ko', Xdata, plane, 'r-')

%This labelled the plot
xLabel(' x (cm)')
yLabel('Normalized Concentration Ca/Co')
clear spline
%This set to functions equal to y and the other to 1-y
f = @(X)plane(X)
g = @(X)1-plane(X)

%quad integrates the function and then matano finds the point where
the
%area under the curve is equal to the area above the curve

matano = @(X)quad(f, 0.1, X) - quad(g, X, 1.6);
fzero(matano, 0.1,1.6)
.



Relevant Pages