I have tried to load a file within a function as shown below:
function dy = rates(t,y)
w= load(ang_rates)
for i=1:8538
wx=w(i,1)
dy = zeros(8538,1);
dy = wx+sin(phi)*tan(theta)*wy+cos(phi)*tan(theta)*wz;
end
end
but it is giving the following error. Also it doesnot show the filename in the workspace.
??? Undefined function or variable 'ang_rates'.
Error in ==> rates at 4
data = load(ang_rates) %# Initialize data with the .MAT file contents
Note that the file is in the same folder as the function.
You are probably looking for
or the equivalent
In your example you try to load something with the name stored in the variable ang_rates (which of course does not exist). Make sure to be ware of the difference between function syntax and command line syntax.