内容が後でプロットされる txt ファイルのファイル名をユーザーに尋ねるスクリプトを作成しようとしています。
filename = input('What is the filename (without the extension) e.g. RCP6: ','s');
if isempty(filename)
filename=input('What is the filename (without the extension) e.g. RCP6: ','s');
end
ext = input('What is the filetype (extension) e.g. .txt: ','s');
if isempty(ext)
ext=input('What is the filetype (extension) e.g. .txt: ','s');
end
filew = strcat(filename,ext)
load(filew)
A = filename
Y = A(:,1)
E = A(:,2)
plot(Y,E)
xlabel('calendar year')
ylabel('annual fossil carbon emissions (GtC)')
書かれているように、コードは filename と ext を正しく連結しますが、load (filew) がそのファイルを正しくロードしているようには見えません。 RCP3PD.txt の値の列?
助言がありますか?他の「文字列からファイルをロードする」スレッドが sprintf() 関数を参照しているのを見たことがありますが、それはここに当てはまりますか?