MATLAB: .m to .mdl

.m to .mdl

hi, i have written a code in editor to find a value ,'phase_delay'
ip = menu('input is','ac','dc')% askin whether input is ac or dc
if ip==1
Vdc=inputdlg('dc output needed = ');
cos_alpha=((Vdc*pi)/(220)-1);
alpha=acosd(cos_alpha);
phase_delay=(alpha)/18000
end
now i want to put this value of phase_delay in "phase delay" of simulink/sources/pulse generator, automatically.

Best Answer

Do you want to set it on a model that is already open? If yes, you can use the set_param command:
>> set_param('path/to/block', 'PhaseDelay', num2str(phase_delay))
Note that phase_delay needs to be converted to a string using num2str because set_param needs the value to be set as a string.