My Matlab script generates a stochastic Load Profile data and I have a simulink model that is getting this data from 'From Workspace' block. I will call this block LP.
What I want to do is; when I copy this LP block and create another block manually from Simulink, I want MATLAB to detect this change and run the model for a new stochastic data for the new block.
My question is if it is possible to achieve ? Otherwise I have to transfer whole model from Matlab to Simulink.
Thanks in advance.
Onat

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2019년 10월 2일

0 개 추천

Right click this "From Workspace" block in your model, select "Properties", select the "Callbacks" panel, select the "CopyFcn" in the left column, on the right panel, type in the MATLAB script or function that generates the stochastic data.

댓글 수: 2

Mustafa Onat Güney
Mustafa Onat Güney 2019년 10월 2일
편집: Mustafa Onat Güney 2019년 10월 2일
Hey, thank you very much for quick answer, very useful feature.When I do that, the new block changes but it overwrites the new data on the previous block as well. (Because 'From Workspace' block reads the same named data). So, I still have one set of data which I actually intend to have seperate data whenever I copy them. Is there a way to lock the initial blocks preventing from change when I callback ?
Best !
Fangjun Jiang
Fangjun Jiang 2019년 10월 2일
What you need is to use set_param() in the CopyFcn callback to change the variable name in the "From Workspace" block and make sure the new data variable name generated in MATLAB matches it. For example
set_param(gcb,'VariableName','NewData')

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by