Error: "Index exceeds matrix dimensions." with find()
Show older comments
Hi, I'm trying to use the find() function to pinpoint a time when the cell culture reaches a specific cell population. However I keep getting the "Index exceeds matrix dimensions" error, and I can't figure out how to fix it. Any help would be greatly appreciated! The problem is on line 27 with the ta=t(a(:,X));
clear all; close all; clc;
%Number of cells introduced to culture
avgAreaCell = 32.5e-7; %cm^2 (range from 25 to 40 um^2)
avgAreaSkin = 20000; %cm^2
apprxTotSkinCell = 3.5e10; %Approximate amount of total skin cells on average adult
numCellBiop = input('Please enter area of biopsy in cm^2 (3cm^2 is recommended): ')/avgAreaCell; %This gives number of cells per unit area of biopsy
disp(' ')
disp(['Number of cells in biopsy is approximately: ' num2str(numCellBiop)]);
disp(' ')
%Set the number of stages & time span
N=16;
tzero=0;
tmax=35;% days/4weeks
tspan=[tzero:0.1:tmax];
I = 0; %No new cells enter. SC pop. is from biopsy
%initial conditions
Xzero=zeros(N,1);
Xzero(1)=numCellBiop;%Start Number of Cells in culture
k=2.2*ones(N-1,1); k(N)=k(1);%Transition rate constants, no death
%integrate the equations
[t,X]=ode45('cell_differentiation_equations',tspan,Xzero,[],N,I,k);
%steady state values for stages 1 to N-1
SS=I/k(1);
X_last=X(length(X),N);
a = find(X(:,N) == apprxTotSkinCell);
ta=t(a(N,:));
disp(['Time when Cell culture reaches Approx. Total of Adult Skin Cells is: ' num2str(ta) ' days']);
2 Comments
Adam
on 8 Dec 2017
Use the debugger. Put a breakpoint on the line in question or select the 'Stop on errors' (or 'Pause on errors' from R2017b) option and then simply look at the size of the relevant components and it will be obvious what is wrong. Certainly more obvious than someone staring at the code trying to work out what size X is.
Eric Cunningham
on 8 Dec 2017
Accepted Answer
More Answers (0)
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!