Translating code from XPP to Matlab
6 views (last 30 days)
Show older comments
Hello everyone!
I'm working on a reaction diffusion model of spreading depression for my honor's thesis. So far, my work has been written in XPP because that's what my adviser used, but he wants to switch over to MatLab because there are features in MatLab that will make it easier to shift our model from 1D to 2D and hopefully 3D. Right now, I'm trying to translate our 1D model into MatLab.
My model's focus is on extracellular potassium and currently, my XPP equation looks like this:
ke[2..49]'=ck*c2*(ik(v[j],n[j],vk[j])+ikpump[j]+ikleak(v[j],vk[j]))+kbuff*(keo-ke[j])-glia*ke[j]+kdiff*(ke[j-1]+ke[j+1]-2*ke[j])
Where j is an element of my ke' vector. Right now my plan is to create a new padded matrix with 0's at the beginning/end, ke2, to incorporate Newman boundary conditions and have something along the lines of
kxx=(ke2(1:end-2)+ke2(3:end)-2*k) then calculate dkdt and then update a temporary matrix k_temp=ke+dkdt*dt. My questions is what would be the easiest way to write dkdt using the functions from my XPP file? I already have unique MatLab function files for all of the functions from XPP but i continuously receive a NaN error whenever I use the following form of dkdt:
dkdt=kxx*kdiff+ck*c2*(ik(v(j), n(j), vk(j))+ikpump(j)+ikleak(v(j), vk(j)))+kbuff*(keo-ke(j))-glia*ke(j);
I think my problem is that I need to use the current cell's extra cellular potassium in order to calculate the Nernst potential which is again used in dkdt; vk=c*log(ke(j)/ki(j)).
I'm sorry if this isn't super clear/dumb question, I just began using MatLab a week ago, and have spent the last couple days reading some books/forums trying to solve this problem.
Any and all help is very appreciated!
3 Comments
per isakson
on 14 Jul 2013
Edited: per isakson
on 14 Jul 2013
Not really. "in the same folder" is that folder included in the Matlab path? File | Set Path ...
Use the debugger; run
dbstop if error
Next, at the offending line run
which the_name_of_my_ODE_ function -all
Answers (0)
See Also
Categories
Find more on Debugging and Analysis 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!