Add Port to SimMechanics Body Block programmatically

조회 수: 2(최근 30일)
Christopher
Christopher 2013년 5월 17일
Hi, currently I am trying to add new CS Ports or the CG Port to a SimMechanics Body block programmatically. Therefore I type into the command line of Matlab: set_param('mdl/Body','CG','Left$CG$[0 0 0]$WORLD$WORLD$m$[0 0 0]$Euler X-Y-Z$deg$WORLD$true$none'). After setting the parameter, there is no error or something. But the parameter change is not taking any effect visually. Only if I open the block parameters and press OK the new Port shows up in the diagram (the hook of "show port" is already set, due to the parameter change).
Does anyone know how the parameter change takes effect (visually) immediately without manual action?
Thank you very much for your help!

답변(2개)

Ryan G
Ryan G 2013년 5월 17일
This is a tough one for me, but I'll try to get you started. I should mention that SimMechanics 2G is now available too.
If you use the function:
get(gcbh,'Ports')
It will display the ports on each side as part of this vector. For me it was
[0 0 0 0 0 1 1 0]
When I updated the block it was
[0 0 0 0 0 2 1 0]
So you would think you could just update this. Unfortunately it appears to be read-only. So I'm not sure how to bypass that. You can modify the xml, which I assume you know about since the set_param command you gave could only be figured out if you understand the model xml. That being said, I highly suggest you avoid doing that if at all possible.

Christopher
Christopher 2013년 5월 21일
Hi Ryan - thanks for your very quick response! We both figured out the same ;) So you would suggest to use SimMechanics Gen2? Would this solve my problem? Or the other way around: Is SimMechanics Gen2 more suitable for a programmatically creation of systems?
Thank you very very much for your help!!
Regards, Chris
  댓글 수: 3
Ryan G
Ryan G 2013년 6월 19일
What is the problem with simulating friction? How are you doing it in 1G that 2G can't do (I'm confident it can). I took a look at more options for the 1G port, but no luck.

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

Community Treasure Hunt

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

Start Hunting!

Translated by