Execute text files in matlab

5 ビュー (過去 30 日間)
Chloe Choi
Chloe Choi 2018 年 11 月 30 日
編集済み: per isakson 2018 年 12 月 1 日
My text files look like:
a = [1, 2, 3, 4, 5]
b = [6, 7, 8, 9, 10]
I want to basically run my text files as if they’re just .m files, and use the variables defined in the text files.
Or is there a way I could just import the variables from these text files?
  2 件のコメント
per isakson
per isakson 2018 年 11 月 30 日
Why not use the extension .m ?
Walter Roberson
Walter Roberson 2018 年 12 月 1 日

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

回答 (1 件)

Mark Sherstan
Mark Sherstan 2018 年 11 月 30 日
Make a text file that looks like this and call it "test.txt":
1, 2, 3, 4, 5
6, 7, 8, 9, 10
Use the following function to load it into MATLAB
load test.txt
Then seperate out your data into its variables:
a = test(1,:);
b = test(2,:);

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by