Variable as placeholder in an "fopen" statement

9 ビュー (過去 30 日間)
Reuben Addison
Reuben Addison 2023 年 2 月 8 日
編集済み: Stephen23 2023 年 2 月 9 日
Still on the issue of a place holder , I am trying to write a code to name the output folder by subject name, I know typically it goes into the braces but this time arround it is not working
''
subject = "PO1"
fid = fopen(['/Users/addison/Documents/Data/"Results2"+{subject}.xls'],'w');
''
  1 件のコメント
Stephen23
Stephen23 2023 年 2 月 8 日
編集済み: Stephen23 2023 年 2 月 9 日
"I know typically it goes into the braces..."
"...but this time arround it is not working"
which is not a big surprise with MATLAB.

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

採用された回答

Les Beckham
Les Beckham 2023 年 2 月 8 日
The way I would do this is this
subject = "PO1";
folder = "/Users/addison/Documents/Data/";
filename = "Results2" + subject + ".xls"
filename = "Results2PO1.xls"
fid = fopen(fullfile(folder, filename));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by