フィルターのクリア

Finding duplicate variables in multiple M files

5 ビュー (過去 30 日間)
John F
John F 2018 年 2 月 26 日
コメント済み: John F 2018 年 2 月 27 日
I am working on a legacy program and have inherited a number of m files that are used for defining parameters in our Simulink models. I want to scan the files to see if there are duplicates or places where a variable is defined multiple times. Is there a simple way to do that?
Thanks!

採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 2 月 26 日
Run each M-file and save a .mat file afterwards (don't forget to run "clear" first each time)
VarList1=fieldnames(load('MFile1.mat')) will give you the variable list in M-file 1.
Use intersect(VarList1, VarList2) to find common variables.
  1 件のコメント
John F
John F 2018 年 2 月 27 日
Thanks Fangjun!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaming Conventions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by