Assigning file name as variable name
古いコメントを表示
Hi everyone,
I would like to write a program. The program must ask users to enter the name of the text we're importing and change the variable name each time. The code I wrote is below:
name = input('Enter the name of a file: ','s');
s=importdata('name.txt');
data=s.data
t_name=data(:,1);
mass_name=data(:,4);
dtg_name=data(:,7);
[ax,p1,p2]=plotyy(t_name,mass_name, t_name,dtg_name,'plot','plot')
I have mainly 2 problems. Importing file from the code generated by input command and assigning t_name, dtg_name etc. variables each time. How can I fix it?
Thank you for your help
採用された回答
その他の回答 (1 件)
Titus Edelhofer
2015 年 7 月 7 日
Hi,
you should use name as a variablename to importdata:
name = input('Enter the name of a file: ','s');
s=importdata(name);
Titus
1 件のコメント
Burak Dermenci
2015 年 7 月 7 日
カテゴリ
ヘルプ センター および File Exchange で Debugging and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!