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일
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 Exchange에서 Get 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