Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Matlab 中,为了改变我做的一个块的值
set_param('model/V','Amplitude','100')
的值为V100。但如果我这样做
V
for i=1:10 set_param('model/V','Amplitude','P(i)') ... end
它存储Vas的值P(i)。但为了访问i20×1 矩阵的第 - 个元素P,我需要通过P(i). 我的错误是什么?
P(i)
i
P
使用以下方法将值更改为字符串:-
set_param('model/V','Amplitude',num2str(P(i)) );
它还将'model/V'的值设置为P(20),即最后一个。
您可能也想遍历当前块
类似的东西:(只是例子)
set_param(['model/V' num2str(i)],'Amplitude',num2str(P(i)) );
为model/V1, model/V2,...model/V20.
model/V1, model/V2,...model/V20