I want to change the name of a variable, X which is the output from my simulink model, according to my input variable, np.
For example:
for i=1:2
np = input(':'); % let's say, for i=1 , np=50
sim('Simulink_Model'); % Output: X
sprintf('X%d',np) = X; % Now I want the output X to be X50
end

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 30일

0 개 추천

Read this http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F you will know that it's not a good idea to create such name variables, you can just use one cell array
for ii=1:2
sim('Simulink_Model'); % Output: X
out{ii} = X;
end

카테고리

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

태그

질문:

Bob
2016년 7월 30일

답변:

2016년 7월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by