3 phase power source change the W variable
3 次查看(过去 30 天)
显示 更早的评论
I have a simulink project which one shows on figure (project name 'UsingMATLABFunction.slx'). We are using 3 phase power source. And i tried take loop. Because we want increase power for each iteration to take different output values.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/653055/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/653060/image.png)
open_system('UsingMATLABFunction.slx');
W=30000;
set_param('UsingMATLABFunction/Source', 'Pref','W');
for ii= 1:10 %% 10 iterations. 10 times power increased.
W=W+10000
x=x+1;
y=y+1;
z=z+1;
set_param('UsingMATLABFunction/Source', 'Pref','W');
sim('UsingMATLABFunction.slx');
save_system('UsingMATLABFunction.slx');
end
I did it like this code but i cant change the current values with source. am i making a mistake somewhere?
0 个评论
回答(1 个)
MULI
2024-4-26
Hi Yusuf,
From the code you have provided it appears that the parameter ‘Pref’ is set to a string ‘W’ instead of setting it with numeric value. Due to this the parameter ‘Pref’ is not updated with the numeric values as you increase ‘W’ in each iteration of the loop.
To correctly update the parameter, convert the numeric value to a string using “num2str” as given below:
set_param('UsingMATLABFunction/Source', 'Pref',num2str(W));
With this correction loop will appropriately increase the value of ‘W’ by 10000 in each iteration.
You may refer to this documentation link for more information on that:
https://www.mathworks.com/help/releases/R2020a/simulink/slref/set_param.html
Hope this answers your query!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Switches and Breakers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!