Display Variable Value In a String

조회 수: 6 (최근 30일)
kayla hernandez
kayla hernandez 2015년 9월 19일
편집: Walter Roberson 2015년 9월 19일
Hello guys,
I have a prbolem and i don't know how to solve it.
X=214 is a vriable
command={
'NACA X'
''
'OPER'
'VISC ON'
'RE'
'160000'
};
id = fopen('command.dat', 'w+');
fprintf(id, '%s\n', comandi{:});
fclose(id);
I have to write the variable command into a .dat file. However my variable X is a number that is into a for cycle and changes his value. With this syntax in the file i will find 'NACA X' but what i need is to find 'NACA 214' for example.
Can someone help me?
Thanks very much

답변 (1개)

Star Strider
Star Strider 2015년 9월 19일
Try this:
X = 214;
command = {sprintf('NACA %d',X) '' 'OPER' 'VISC ON' 'RE' '160000' };

카테고리

Help CenterFile Exchange에서 Aerodynamics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by