- Open the Simulink model.
- Get the path of the block whose parameters you want to change.
- Use 'set_param' to change the parameters.
how to changes for two parameters values in simulink block at same time in matlab 2022. this function is already founded in matlab 2016
12 views (last 30 days)
Show older comments
Freq=0;F=0; n=0;A=0;
for k=1:20 Freq=Freq+50; n=n+1;
sim('Rc_model22');
if k==1 t=Vcamp(:,1);Vcamp1(:,1)=Vcamp(:,2); AVc1(:,1)=AVc(:,2); end;
if k==2 Vcamp2(:,1)=Vcamp(:,2); AVc2(:,1)=AVc(:,2);end;
if k==3 Vcamp3(:,1)=Vcamp(:,2); AVc3(:,1)=AVc(:,2);end;
if k==4 Vcamp4(:,1)=Vcamp(:,2); AVc4(:,1)=AVc(:,2);end;
if k==5 Vcamp5(:,1)=Vcamp(:,2); AVc5(:,1)=AVc(:,2);end;
if k==6 Vcamp6(:,1)=Vcamp(:,2); AVc6(:,1)=AVc(:,2);end;
if k==7 Vcamp7(:,1)=Vcamp(:,2); AVc7(:,1)=AVc(:,2);end;
if k==8 Vcamp8(:,1)=Vcamp(:,2); AVc8(:,1)=AVc(:,2);end;
if k==9 Vcamp9(:,1)=Vcamp(:,2); AVc9(:,1)=AVc(:,2);end;
if k==10 Vcamp10(:,1)=Vcamp(:,2); AVc10(:,1)=AVc(:,2);end;
if k==11 Vcamp11(:,1)=Vcamp(:,2); AVc11(:,1)=AVc(:,2);end;
if k==12 Vcamp12(:,1)=Vcamp(:,2); AVc12(:,1)=AVc(:,2);end;
if k==13 Vcamp13(:,1)=Vcamp(:,2); AVc13(:,1)=AVc(:,2);end;
if k==14 Vcamp14(:,1)=Vcamp(:,2); AVc14(:,1)=AVc(:,2);end;
if k==15 Vcamp15(:,1)=Vcamp(:,2); AVc15(:,1)=AVc(:,2);end;
if k==16 Vcamp16(:,1)=Vcamp(:,2); AVc16(:,1)=AVc(:,2);end;
if k==17 Vcamp17(:,1)=Vcamp(:,2); AVc17(:,1)=AVc(:,2);end;
if k==18 Vcamp18(:,1)=Vcamp(:,2); AVc18(:,1)=AVc(:,2);end;
if k==19 Vcamp19(:,1)=Vcamp(:,2); AVc19(:,1)=AVc(:,2);end;
if k==20 Vcamp20(:,1)=Vcamp(:,2); AVc20(:,1)=AVc(:,2);end;
end
0 Comments
Answers (1)
Manish
on 31 Jan 2025
Edited: Manish
on 31 Jan 2025
Hi ehab,
I understand that you want to change multiple parameter values in a Simulink block at the same time. This can be achieved by using the 'set_param' function.
Refer to the steps below to change multiple parameters:
Sample Code:
blockPath = 'your_model_name/your_block_name';
% New parameter values
param1Name = 'Parameter1';
param1Value = 'newValue1';
param2Name = 'Parameter2';
param2Value = 'newValue2';
% Set the parameters
set_param(blockPath, param1Name, param1Value, param2Name, param2Value);
Refer to the documentation link for better understanding:
Hope it helps.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!