Can Simscape domains be defined with vectors?

조회 수: 4 (최근 30일)
cmmcnamara
cmmcnamara 2020년 8월 15일
댓글: cmmcnamara 2020년 8월 21일
Hello,
I am working on creating a custom Simscape domain and I am trying to determine if I can define both my Through and Across variables in terms of vectors. I understand that according to this following post, Simscape can handle vector and matrix equations but its not clear if the variables may be defined in the domain this way:
I'd like to basically define something along the lines of this:
variables
R = { [0;0] , 'W/sr' };
end
variables(Balancing = true)
Q = { [0;0] , 'W' };
end
This would lead to matrix operations in my component's equations so I don't feel simulation speed will improve due to lesser nodes but it will be easier to follow on the block diagram and clear.
Is this possible?
  댓글 수: 1
cmmcnamara
cmmcnamara 2020년 8월 15일
As a follow up to this, I haven't been successful yet for my particular development, but it does appear possible after digging around in some of the Simscape default domains. Specifically I was able to find this:
variables
V = { [ 0 0 0 ], 'V' };
end
variables(Balancing = true)
I = { [ 0 0 0 ], 'A' };
end
So it appears as if it is certainly possible. Still not sure if it must be row vectors vs column or anything but I thought it would be good to note if anyone else had the same questions.

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

답변 (1개)

Yifeng Tang
Yifeng Tang 2020년 8월 21일
Yes. It's possible. I wonder where you find the quoted code, because I've been using [0;0;0] format not knowing it's OK the other way, too.
For these vector variables or parameters, you may functions like sum and dot to perform vector manipulations. You can also use syntax like V(1) or V(3:end) to define equations on specific components. If I manage to find more complete documentation on this, I'll post again.
Whenever I'm not sure how I should write the equations for the vector variables, I found it convenient to try things out in PS first. PS constant can be vectors, too. So I can write blocks in PS domain and have a scope to look at them. If things all behave as expected, I would implement the equations in the actual domain.
Hope this helps.
Yifeng
  댓글 수: 1
cmmcnamara
cmmcnamara 2020년 8월 21일
Thank you for all of these tips.
For reference the quoted code I took from the "3 Phase Electrical Domain" but I wasn't sure if I could post the whole .ssc file or not and just posted the snippet. There's also other domains similar to this doing 6 phase, 12 phase and even 24 phase domains I was able to find in "+electrical".
Also thank you for the tip on the PS blocks as a probing method, this is exactly what I have found myself doing for checking out behavior before implementing it in the domain itself.
I have not been able to have success in using column vector format but row vector works flawlessly. It possibly could be my fault missing a proper transpose somewhere in my code but stopped digging once the row vector routines were working.
I would definitley appreciate posting further documentation if you find it. I have found the sum function quite useful because the domain I am working on has an interface to the Thermal domain where I need to sum the Through variables in my domain to transfer to the single Through variable for heat flow in Thermal. Thank you for the pointer on the syntax hint for things like X(1) or X(3:end) because that will be incredibly helpful in making my domain more modular.
Along this same lines, do you know if it is possible to make these domain vectors variable since you can describe the equations using vector notation like X(3:end)? My domain currently consists of 2 x 1 row vectors but it would be nice if it could be N x 1 row vectors the user specifies depending on the fidelity needed. I don't know how this would be accomplished though except for maybe a domain settings block that propogates the value N to the domain elements.

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

카테고리

Help CenterFile Exchange에서 Foundation and Custom Domains에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by