how to make a file .mat as a function input and load it inside the function

16 ビュー (過去 30 日間)
rachida
rachida 2019 年 7 月 21 日
コメント済み: Walter Roberson 2019 年 7 月 21 日
Hey everyone
I am developping a function and i need a A.mat as an infile input of the function B , inside the function i hav to do file load , and to say that the function and the A.mat are in the same directory. so the alogorithme would be like thise
function B(filemat)
load filemat
thank you

採用された回答

Walter Roberson
Walter Roberson 2019 年 7 月 21 日
編集済み: Walter Roberson 2019 年 7 月 21 日
data = load(filemat);
Now the variables you need will each be fieldnames of the struct data
  2 件のコメント
rachida
rachida 2019 年 7 月 21 日
i know this, my prob isnot loading , my question is about how can i let the function able to find this file.mat that i want ,
thanks for your answer
Walter Roberson
Walter Roberson 2019 年 7 月 21 日
You were using
load filemat
which is equivalent to
load('filemat')
which ignores the content of the variable named filemat and instead tries to load something literally named filemat.mat
My suggested code uses the content of the variable named filemat to see where it should load

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by