How can I declare a string variable which I can call when loading a filename?

I want to plot files amongst which the only thing that changes is a word. Therefore, I want to declare a variable which I can call in the filename. Model=(CanESM); load('Model.mean.dat'); ...

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 25일
편집: Azzi Abdelmalek 2016년 7월 25일
model='Model.mean.dat'
load(model);

댓글 수: 3

Maria Py
Maria Py 2016년 7월 25일
편집: Maria Py 2016년 7월 25일
I understand what you want to say, but I want to declare the string 'Model' as a variable and not the whole file. I want to write "Model" in the filename and read the file CanESM.mean.dat.
Model = 'CanESM';
load( [Model '.mean.dat'] )
Model='CanESM';
file=sprintf('%s.mean.dat',Model)
load(file)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

질문:

2016년 7월 25일

댓글:

2016년 7월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by