Define constant variables in SSC, without specifiying them as parameter.
2 views (last 30 days)
Show older comments
Hi I came across a problem in defining constants in ssc. This covers on one hand really constant constants as e.g. e. But also some problem specific konstants which I might like to not make available as parameter.
If I'd like to use e in the equations block, I have always to write it as 2.71828182846. The standard way of using it normally (exp(1)) does not work in the equations block as exp is not an accepted function. This Method is OK for real natural constants, but for problem specific constants this would mean, that I have to switch all occurances of this constant manually. (And if the constant is e.g. 2 then there will certainly be some occurences of "2" in the code, which are associated to this constant, and others which are not.) --> Works but might become difficult in maintaining the code.
Another way would be to define e as parameter. But then the enduser might adapt this "constant" to other values, which makes no sense. Something like a hidden parameter would be required.
parameters
R = { 1.05, 'm' }; % Wheel radius
I = { 5.05, 'kg*m^2' }; % Wheel inertia
end
parameters {Hidden} <-- Does something like this work.
Restitution_factor = {0.001, '1'}
end
A last version would be set the constant as variable. And the fix it in the equations block, which makes no sense to me.
variables(Access=private)
Restitution_factor = {0.001, '1'} % restitution factor
end
equation
Restitution_factor == {0.001, '1'}
... other equations using Restitution_factor
end
Any recommendation on how to do this?
0 Comments
Answers (0)
See Also
Categories
Find more on Manual Performance Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!