user2579666
user2579666

Reputation: 1

Load a file inside a function in matlab

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.

Upvotes: 0

Views: 281

Answers (1)

Dennis Jaheruddin
Dennis Jaheruddin

Reputation: 21563

You are probably looking for

load('ang_rates.mat')

or the equivalent

load ang_rates  

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.

Upvotes: 1

Related Questions