フィルターのクリア

A small question about load matrix

1 回表示 (過去 30 日間)
Tommy
Tommy 2012 年 5 月 7 日
I want to load a matrix in a function, so I save the matrix of "randn(M,N)" as "randn_DBba_modified.mat". In the function below:
...
Mat=load('randn_DBba_modified.mat');
...
for j=1:N
...
asset(:,j+1)=asset(:,j)+((asset(:,j).*(r+omega*(mu-r)))+40*contri(:,j)-15*b(:,j))*dt+omega*sigma*asset(:,j)*sqrt(dt).*Mat(:,j);%asset function
...
and get the error notification of "??? Undefined function or method 'times' for input arguments of type 'struct'.
Error in ==> function_1_3_2 at 39 asset(:,j+1)=asset(:,j)+((asset(:,j).*(r+omega*(mu-r)))+40*contri(:,j)-15*b(:,j))*dt+omega*sigma*asset(:,j)*sqrt(dt).*Mat(:,j);%asset function"
I bypass the useless code above.
I want to know where I did is wrong since if I set a matrix in the code instead of loading one, the function works well.
Thank you.

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 5 月 7 日
dbstop if error
Then run the code. The debugger will stop on the line causing the error. It should be obvious at this point.
OKAY, hint! The mat file loaded as a struct since you assigned it to a variable. If you want to load the variables individually:
load mymatile.mat
If you want to load them to a struct, do as you did but then reference them by:
Mat.varName
  1 件のコメント
Tommy
Tommy 2012 年 5 月 7 日
THX a lot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by