How to use a variable from script in a function that is in another script
Hello, I am coding a 2nd order differential solver and need to call a variable from the main script into a function script as shown below. I have tried using global however I have read that it is not accepted practice. Also note x2 and x3 are stored in another script called solver.m. Thank you!
fx2x3.m:
function dv3dt = fx2x3 (x2,x3)
dv3dt = ((k3)/(m3))*(x2-x3); %numbers substituted immediately to reduce lines
endHello, I am coding a 2nd order differential solver and need to call a variable from the main script into a function script as shown below. I have tried using global however I have read that it is not accepted practice. Also note x2 and x3 are stored in another script called solver.m. Thank you!
fx2x3.m:
function dv3dt = fx2x3 (x2,x3)
dv3dt = ((k3)/(m3))*(x2-x3); %numbers substituted immediately to reduce lines
end Hello, I am coding a 2nd order differential solver and need to call a variable from the main script into a function script as shown below. I have tried using global however I have read that it is not accepted practice. Also note x2 and x3 are stored in another script called solver.m. Thank you!
fx2x3.m:
function dv3dt = fx2x3 (x2,x3)
dv3dt = ((k3)/(m3))*(x2-x3); %numbers substituted immediately to reduce lines
end matlab code MATLAB Answers — New Questions