modify .m file using a .m file
Show older comments
I have a .m file called ilap.m and I need to change one line of this code inside of another .m file, called main.m. I know that similar questions have been asked before, but I have no experience doing something like this, so I do not understand these explanations. Therefore, it would be nice if someone could show me an easy example so that I could understand how to perform this task.
Thanks in advance!
2 Comments
KSSV
on 12 Oct 2022
What changes you want to make? How the .m file is?
Wout Laeremans
on 12 Oct 2022
Edited: Wout Laeremans
on 12 Oct 2022
Answers (1)
So you make k_off as an input to the function and call it in a loop.
% Main function
k_off = 0:0.1:1 ;
m = length(k_off) ;
F = zeros(m,1) ;
p = rand ;
for i = 1:m
F(i) = ilap(p,k_off(i)) ;
end
plot(k_off,F)
function F = ilap(p,k_off)
a = 1;
k = 11*3.9/0.44^2;
k_plus = 5;
k_on = k_plus;
k_onstar = k_on/a^2;
w = 20*a;
D_f = a^2*k;
% k_off = 0.5; % This is made as input
F_eq = k_off./(k_onstar + k_off);
C_eq = k_onstar./(k_onstar + k_off);
F = 1./p - F_eq./p.*(1 - 2.*besselk(1,sqrt(p./D_f.*(1 + k_onstar./(p+k_off))).*w).*besseli(1,sqrt(p./D_f.*(1 + k_onstar./(p+k_off))).*w)).*(1+k_onstar./(p+k_off)) - C_eq./(p+k_off);
end
1 Comment
Wout Laeremans
on 12 Oct 2022
Categories
Find more on MATLAB 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!