필터 지우기
필터 지우기

How to change the value of constant while simulation is running

조회 수: 101 (최근 30일)
Samah EL QASSAH
Samah EL QASSAH 2017년 6월 30일
댓글: Mikhail Savastianov 2021년 10월 22일
Hi,
I would like to change the value of a constant on simulink but I get the following error:
"Cannot change parameter 'Value' of 'untitled/Constant' while simulation is running. The block was made virtual as it was optimized for simulation"
Somebody please help me in this regard
  댓글 수: 1
Adam
Adam 2017년 6월 30일
I don't use Simulink, but surely the whole purpose of a constant is that it is constant?!

댓글을 달려면 로그인하십시오.

답변 (3개)

Vincent Nicolazzo
Vincent Nicolazzo 2019년 3월 6일
Check out this link. It's not the best method but it worked for me. I would run my simullation and change the value of the constant in the command window.

Roadrunner Development
Roadrunner Development 2020년 5월 18일
I had the same issue. When you run simulation, and want to change the paramter in real-time, use set_param command line function. However, enable that signal for logging before running the simulation. I do not know why is this so, but I found it out by chance, and it works.
On the other hand, if you run real-time code on a target machine (speedgoat for example), use setparam and getparam. No logging necessary.
  댓글 수: 1
Mikhail Savastianov
Mikhail Savastianov 2021년 10월 22일
Hi! Your advice does not work for me. I can change parameters during the simulation only. When I run my model on hardware in real time, nothing works (neither slider, nor setparam). Logging the signal does not change anything.

댓글을 달려면 로그인하십시오.


Saeed Ahmadzadeh Mahboobi
Saeed Ahmadzadeh Mahboobi 2020년 11월 19일
If you want to do it during the simulink simulation, then the block "IC" in simulink/sinks , which is a "initial condition" block, and can change in each simulink iteration, might be helpful.

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by