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 ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Mark Sherstan
Mark Sherstan 2018년 11월 30일

1 개 추천

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,:);

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

태그

질문:

2018년 11월 30일

편집:

2018년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by