I wrote the script that calls few functions, they were written in order to optimize work of the script. My error is
Trabalho1NaN/Inf breakpoint hit for fullfile.p on line 28.29 persistent fileSeparator;
it occurs in line
alfan(i) = an(vm(i));
that calls function 'an' using vm(i) as input. I don't use fullfile and I don't understand why it happens. All files are in the same folder, my working directory.
Full code:
%%Input dado pelo usuário
prompt = {'Insira o valor da corrente de estímulo Is (em unidades de mA/cm^2):','Insira o valor do tempo total T (em unidades de ms):','Insira o valor do tempo do início da estimulaçao (em unidades de ms):','Insira o valor da duracao do estimulo (em unidades de ms):','Insira o tamanho do passo temporal (em unidades de ms):','Insira o valor da temperatura (em unidades de C):'};dlg_title = 'Estímulo';num_lines = 1;answer = inputdlg(prompt,dlg_title,num_lines);Is = str2double(answer{1}); % um corrente de estímulo Is [mA/cm^2]
T = str2double(answer{2}); % tempo total [ms]
ti = str2double(answer{3}); % inicio [ms]
td = str2double(answer{4}); % duracao [ms]
dt = str2double(answer{5}); %[ms]
TC = str2double(answer{6}); % temperatura [C]
% O ciclo para testar os limites das variaveis da entrada
while(1) if (Is < 0) || ((ti+td)>T) || (T<30) prompt = {'Insira o valor da corrente de estímulo Is (em unidades de mA/cm^2):','Insira o valor do tempo total T (em unidades de ms):','Insira o valor do tempo do início da estimulaçao (em unidades de ms):','Insira o valor da duracao do estimulo (em unidades de ms):','Insira o tamanho do passo temporal (em unidades de ms):','Insira o valor da temperatura (em unidades de C):'}; dlg_title = 'Estímulo'; num_lines = 1; answer = inputdlg(prompt,dlg_title,num_lines); Is = str2double(answer{1}); % um corrente de estímulo Is [mA/cm^2] T = str2double(answer{2}); % tempo total [ms] ti = str2double(answer{3}); % inicio [ms] td = str2double(answer{4}); % duracao [ms] dt = str2double(answer{5}); %[ms] TC = str2double(answer{6}); % inicio [C]
else break; endend%%Cálculos
% tempo
% y = linspace(x1,x2,n) generates n points. The spacing between the points is dt = (T-0)/(np-1).
np = (T/dt)+1; %number of iterations
t = linspace(0,T,np); %[ms]% pontos do inicio e fim
npi = ti*(1/dt);tf = ti + td;npf = tf*(1/dt);% Potenciais de Nernst
[ EK, ENa, EL ] = nernst( TC );% Condutancias
gK = zeros(1,np);gNa = zeros(1,np);% Correntes [uA/cm^2]
Im = zeros(1,np);IK = zeros(1,np);INa = zeros(1,np);IL = zeros(1,np);Ii = zeros(1,np);Ic = zeros(1,np);% Potenciais [mV]
Vm = zeros(1,np);dVm = zeros(1,np);vm = zeros(1,np);% Alfas e betas [ms^-1]
alfan = zeros(1,np);betan = zeros(1,np);alfam = zeros(1,np);betam = zeros(1,np);alfah = zeros(1,np);betah = zeros(1,np);% probabilidades
dn = zeros(1,np);dm = zeros(1,np);dh = zeros(1,np);n = zeros(1,np);m = zeros(1,np);h = zeros(1,np);% constantes
Vr = 60.0; %[mV]
Cm = 0.001; %[mF/cm^2]
gKmax = 36.0; %[mS/cm^2]
gNamax = 120.0; %[mS/cm^2]gL = 0.3; %[mS/cm^2]dbstop if naninffor i = 1:npif (i <= npi) || (i >= npf) %antes e depois de estimulacao
%Potenciais
Vm(i)= -60.0; vm(i) = Vm(i) - Vr; %condutanciais
gK = 0.367; gNa = 0.011; % probabilidades n(i) = 0.31768; m(i) = 0.05293; h(i) = 0.59612; % inicio
if i==npi Im(i)= Is; dVm(i) = dt*(Is/Cm); Vm(i) = Vm(i-1) + dVm(i); vm(i) = Vm(i) - Vr; else Im(i)= 0; endelse % corrente transmembranar
Im(i) = Is; %potencial de membrana
dVm(i)= (dt/Cm)*(Im(i-1)-Ii(i-1)); Vm(i) = Vm(i-1) + dVm(i); vm(i) = Vm(i) - Vr; %alfas e betas
alfan(i) = an(vm(i)); betan(i) = 0.125*exp(-vm(i)/80); alfam(i) = am(vm(i)); betam(i) = 4*exp(-vm(i)/18); alfah(i) = 0.07*exp(-vm(i)/20); betah(i) = 1/(exp((30-vm(i))/10)+1); %n, m, h
dn(i) = dt*(alfan(i)*(1-n(i-1)) - betan(i)*n(i-1)); dm(i) = dt*(alfam(i)*(1-m(i-1)) - betam(i)*m(i-1)); dh(i) = dt*(alfah(i)*(1-h(i-1)) - betah(i)*h(i-1)); n(i)= n(i-1)+dn(i); m(i)= m(i-1)+dm(i); h(i)= h(i-1)+dh(i); %condutancias [mS/cm^2]
gNa(i) = gNamax*(m(i)^3)*h(i); %[mS/cm^2] gK(i) = gKmax*(n(i)^4); % Potenciais de Nernst % correntes ionicas %[uA/cm^2]
INa(i)= gNa(i)*(Vm(i)-ENa); IK(i) = gK(i)*(Vm(i)-EK); IL(i) = gL*(Vm(i)-EL); Ii(i) = IK(i) + INa(i) + IL(i); % corrente capacitiva [uA/cm^2]
Ic(i) = Cm*(dVm(i)/dt); endend%%Gráficos
figure(1)%Im
subplot(2,3,1)plot(t,Im)xlabel('Tempo','FontSize',12); ylabel('Corrente transmembranar [mA/cm^2]','FontSize',12);%INa, IK
subplot(2,3,2)plot(t,INa,t,IK)xlabel('Tempo','FontSize',12); ylabel('Correntes ionicas [mA/cm^2]','FontSize',12);legend('corrente do sodio','corrente do potassio');%gNa, gK
subplot(2,3,3)plot(t,gNa,t,gK)xlabel('Tempo','FontSize',12); ylabel('Condutancias do potassio e sodio [mS/cm^2]','FontSize',12);legend('condutancia do sodio','condutancia do potassio');%Vm
subplot(2,3,4)plot(t,Vm)xlabel('Tempo','FontSize',12); ylabel('Potencial da membrana [mV]','FontSize',12);%n, m, hsubplot(2,3,5)plot(t,n,t,m,t,h)xlabel('Tempo','FontSize',12); ylabel('Gating','FontSize',12);legend('n','m','h');function [ alfan ] = an( vm )if vm == 10 alfan = 0.1;else alfan = (0.01*(10-vm))/(exp((10-vm)/10)-1);endendfunction [ alfam ] = am(vm)if vm == 25 alfam = 1;else alfam = (0.1*(25-vm)/(exp((25-vm)/10)-1));endend
MATLAB R2015a Thank you in advance.
Best Answer