Variable as placeholder in an "fopen" statement

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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

製品

リリース

R2022b

質問済み:

2023 年 2 月 8 日

編集済み:

2023 年 2 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by