I have a problem when I convert a char into a variable name

num = [1];
dem = [1 1 0 0];
T=[0.1,0.5,2,3,4,20]
R=["A","B","C","D","E","F"]
for i=1:length(T)
for j=1:length(R)
R(j) = tf(num ,dem,'Inputdelay',T(i)); %% error
end
for plotId = 1 : 6
subplot(3,2,plotId), bode(R(j))
grid on;
title(['delay=',num2str(T(plotId))])
end
end

1 件のコメント

Stephen23
Stephen23 2021 年 12 月 13 日
編集済み: Stephen23 2021 年 12 月 13 日
What is the expected result of allocating a tf model object (or genss model object or uss model object) to a string array?

サインインしてコメントする。

 採用された回答

Steven Lord
Steven Lord 2021 年 12 月 13 日

1 投票

Can you create dynamically named variables like this? Yes.
Should you do this? The general consensus is no. See that Answers post for an explanation and alternatives.

2 件のコメント

abdelkrim bensmaine
abdelkrim bensmaine 2021 年 12 月 15 日
I dont understand how it works, would you please simplify it for me or help me in this case?
Rik
Rik 2021 年 12 月 15 日
@abdelkrim bensmaine, your new question essentially duplicates this one. Please don't post duplicate posts on a single topic. This divides effort over several threads.
@others: for the follow-up, see this thread.

サインインしてコメントする。

その他の回答 (0 件)

質問済み:

2021 年 12 月 13 日

コメント済み:

Rik
2021 年 12 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by