Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert the following matlab code to C+ steps = 500; %This simulation runs for 500 steps count = 0; count1 = 0; newfunc = [];

Convert the following matlab code to C+

steps = 500; %This simulation runs for 500 steps

count = 0; count1 = 0;

newfunc = []; newfunc1 = [];

a=0.02; b=0.25; c=-65; d=6; V=-64; u=b*V; V1=-64; u1=b*V1; w=100; VV=[]; VV1=[]; uu=[]; uu1=[]; tau = 0.25; tspan = 0:tau:steps; %tau is the discretization time-step %tspan is the simulation interval T1=50; %T1 is the time at which the step input rises I = 0:0.25:20; for new = 1:length(I) for t=tspan V = V + tau*(0.04*V^2+5*V+140-u+I(new)); u = u + tau*a*(b*V-u); if V > 30 VV(end+1)=30; %VV is the time-series of membrane potentials V = c; u = u + d; if t > 200 count = count+1; end I_B = w*1; else VV(end+1)=V; I_B = w*0; end; V1 = V1 + tau*(0.04*V1^2+5*V1+140-u1+I_B); u1 = u1+tau*a*(b*V1-u1); if V1 > 30 VV1(end+1) = 30; V1 = c; u1 = u1 + d; if t > 200 count1 = count1+1; end else VV1(end+1) = V1; end uu(end+1)=u; uu1(end+1)=u1; end; newfunc(new)=count/300; newfunc1(new)=count1/300; count = 0; count1 = 0; VV = []; VV1 = []; end I_A = 1:length(I); figure(1) subplot(2,1,1) plot(I_A,newfunc,'r*-'); axis([0 max(I_A) 0 max(newfunc)])

subplot(2,1,2) plot(I_A,newfunc1,'b*-'); axis([0 max(I_A) 0 max(newfunc1)])

figure(2) plot(newfunc,newfunc1,'m*');

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago