Unrecognized function or variable 'm_equations'
2 ビュー (過去 30 日間)
古いコメントを表示
Please help me to resolve the following error.
Error in untitled (line 38)
[alphaM, betaM] = m_equations(V(1), Vrest)
The code is
clear all; close all; clc;
Vrest = 0; % mV− change this to −65 ifdesired
dt = 0.01; % ms
totalTime = 150; % ms
C = 20; % uF/cm^2
V_1 = -1.2; % mV
V_2 = 18; % mV
V_3 = 2; % mV
V_4 = 30; % mV
V_Ca = 120; %mV %Reversal potential for Ca2+ current
V_K = -84; %mV %Reversal potential for K+ current
V_Leak = -60; %mV %Reversal potential for leak current
g_Ca = 4.4; % mS/cm^2 % Maximal conductance associated with Ca2+ current
g_K = 8; % mS/cm^2 % Maximal conductance associated with K+ current
g_Leak = 2; % mS/cm^2 % Conductance associated with leak current
phi = 0.04; %1/ms %Rate scaling parameter
% Vector oftimesteps
t = [0:dt:totalTime];
% samples = length(t);
V = zeros(size(t));
% Current input −− change this to see how different inputs affect the neuron
I_current = ones(1,length(t))*0.0;
I_current(50/dt:end) = 90; % Input of 90 microA/cm2 beginning at 50 ms and steady until end of time period.
% initializing values
V(1) = Vrest; % membrane potential is starting at its resting state
% separate functions to get the alpha and beta values
[alphaM, betaM] = m_equations(V(1), Vrest);
[alphaW, betaW] = w_equations(V(1), Vrest);
% initializing gating variables to the asymptotic values when membrane potential
% is set to the membrane resting value based on equation 13
m(1) = (alphaM / (alphaM + betaM));
w(1) = (alphaW / (alphaW + betaW));
% repeat for time determined in totalTime , by each dt
for i = 1:length(t)
% calculate new alpha and beta based on last known membrane potenatial
[alphaM, betaM] = m_equations(V(i), Vrest);
[alphaW, betaW] = w_equations(V(i), Vrest);
% conductance variables − computed separately to show how this
% changes with membrane potential in one ofthe graphs
conductance_Ca(i) = g_Ca*(m(i));
conductance_K(i)=g_K*(w(i));
% retrieving ionic currents
I_Ca(i) = conductance_Ca(i)*(V(i)-V_Ca);
I_K(i) = conductance_K(i)*(V(i)-V_K);
I_Leak(i) = g_Leak*(V(i)-V_Leak);
% Calculating the input
Input = I_current(i) - (I_Ca(i) + I_K(i) + I_Leak(i));
% Calculating the new membrane potential
V(i+1) = V(i) + Input* dt*(1/C);
% getting new values for the gating variables
m(i+1) = m(i) + (alphaM *(1-m(i)) - betaM * m(i))*dt;
w(i+1) = w(i) + (alphaN *(1-w(i)) - betaN * w(i))*dt;
end
figure('Name', 'Gating Parameters')
plot(t(45/dt:end),m(45/dt:end-1), 'r',t(45/dt:end), w(45/dt:end-1), 'b', 'LineWidth', 2)
legend('m', 'W')
xlabel('Time (ms)')
ylabel('')
title('Gating Parameters')
figure('Name', 'Membrane Potential vs input')
subplot(2,1,1)
plot(t(45/dt:end),V(45/dt:end-1), 'LineWidth', 2)
xlabel('Time (ms)')
ylabel('Voltage (mV)')
title('Action Potential')
xlabel('Time (ms)')
% Special graph to show ionic current movement
Vrest = 0;
voltage = [-100:0.01:100];
for i = 1:length(voltage)
[alphaM, betaM] = m_equations(voltage(i), Vrest);
[alphaW, betaW] = w_equations(voltage(i), Vrest);
taum(i) = 1/(alphaM+betaM);
tauw(i) = 1/(alphaW+betaW);
xm(i) = alphaM/(alphaM+betaM);
xw(i) = alphaw/(alphaw+betaw);
aM(i) = alphaM;
bM(i) = betaM;
aM(i) = alphaM;
bW(i) = betaW;
end
figure('Name', 'Equilibrium Function');
plot(voltage, xm, voltage, xw,'LineWidth', 2);
legend('m', 'w');
title('Equilibrium Function');
xlabel('mV');
ylabel('x(u)');
xlabel('Time (ms)')
function MorrisLecar
%%%%%%%% functions section - always after main code %%%%%%%%%%%%%%%
% calculate alpha m and beta m
function [alpha_m, beta_m] = m_equations(phi,V,V_1,V_2,V_3,V_4)
alpha_m = 0.5*phi* cosh((V-V3)/(2*V4))*(1 + tanh((V-V1)/V2));
beta_m = 0.5*phi* cosh((V-V3)/(2*V4))*(1 - tanh((V-V1)/V2));
end
% calculate alpha w and beta w
function [alpha_w, beta_w] = w_equations(phi,V,V_3,V_4)
alpha_m = 0.5*phi* cosh((V-V3)/(2*V4))*(1 + tanh((V-V3)/V4));
beta_m = 0.5*phi* cosh((V-V3)/(2*V4))*(1 - tanh((V-V3)/V4));
end
end
0 件のコメント
回答 (1 件)
Simon Chan
2022 年 6 月 16 日
Move the line function MorrisLecar to be the first line of your entire code.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Debugging and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!