- Index
- » Users
- » arvinmor
- » Profile
Posts
Posts
Here it is:
Code:
model tmp
// Modelica.Blocks.Sources.Step step1(startTime = 2) annotation(Placement(visible = true, transformation(origin = {-20, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
// parameter Real[:] b = {1, 2};
// Real[3] c = {2, 3, 4};
// Real[:,1] d = [b; c];
// parameter Real b1[:, 1] = [zeros(max(0, 0), 1); b];
// parameter Real bb[:] = vector(b1);
// parameter Real a[:,1] = {{1}};
// parameter Real aa[:] = vector(a);
// vector([zeros(0,1);1]);
Modelica.Blocks.Continuous.TransferFunction transferfunction1 annotation(Placement(visible = true, transformation(origin = {0, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Sources.Step step1(startTime = 1) annotation(Placement(visible = true, transformation(origin = {-40, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(step1.y, transferfunction1.u) annotation(Line(points = {{-29, 0}, {-12.8668, 0}, {-12.8668, 0.677201}, {-12.8668, 0.677201}}, color = {0, 0, 127}));
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-06, Interval = 0.01));
end tmp;
forget the comments. i just wrote them to go step by step through the TransferFunction code and find out how the error is produced.
Thanks,
Arvin
Hello,
When using "Modelica.Blocks.Continuous.TransferFunction" with a={1} and b={1}, the following error and warning shows up:
[CodegenC.tpl:8994:11-8994:11] Error: Template error: vector() call does not have a C implementation vector({{transferfunction1.b[1]}})
[C:/OpenModelica/lib/omlibrary/Modelica 3.2.1/Blocks/Continuous.mo:1244:5-1244:61] Warning: Failed to deduce dimensions of bb due to unknown dimensions of modifier vector({{transferfunction1.b[1]}}).
Looking at TransferFunction code, the problem comes from the vector function in the following line:
bb[:] = vector([zeros(max(0, na - nb), 1); b]);
which for my case it simply become:
bb[:] = vector({{transferfunction1.b[1]}});
why vector function can not convert {{transferfunction1.b[1]}} to a vector?
Thanks,
Arvin
Hello,
I have written a function which supposed to calculate bi-nominal coefficients as bellow:
Code:
function binom_coef
input Integer n;
output Integer coef[n+1];
algorithm
for i in 0:n loop
coef[i + 1] := comb(n, i);
end for;
end binom_coef;
class test_binom_coef
parameter Integer n = 3;
parameter Integer a[:] = binom_coef(n);
end test_binom_coef;
in which comb(n,i) calculates combination of k from n.
my question is regarding to binom_coef function which i get n as input and then i want to define a vector of n+1 elements. when i run this code i get the following error:
[:3:3-3:27] Error: Dimensions must be parameter or constant expression (in 1 + n).
please help me with an alternative for this code.
Thanks,
Arvin
Hello,
is it possible to implement the following transfer function using for loop as an array of connected simpler blocks:
Y=[((1+sT1)/(1+sT2)^M)^N]*U where M and N are input parameters. and U is input and Y is output.
Thanks,
Arvin
Hello,
i have written a program which detects crossing zeros from positive to negative. to do this, i have connected my source, a sine wave for instance to "Modelica.Blocks.Logical.LessEqualThreshold" block with threshold=0, and the output of this block is connected to "Modelica.Blocks.MathBoolean.RisingEdge" block. by this mean anytime value of the sine wave bocomes smaller or equal to zero the output of the comparator becomes one and which trigers the rising edge detection block and the output should generate a pulse consequently.
however when i look at the output of risingedge block it always remains zero.
please help me with this issue.
Thanks,
Arvin
PS: code is attached.
Code:
model tmp1
Modelica.Blocks.Sources.Sine sine1(amplitude = 2, freqHz = 1, offset = 0) annotation(Placement(visible = true, transformation(origin = {-60, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Logical.LessEqualThreshold lessequalthreshold1 annotation(Placement(visible = true, transformation(origin = {-20, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.MathBoolean.RisingEdge rising1 annotation(Placement(visible = true, transformation(origin = {20, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(rising1.u, lessequalthreshold1.y) annotation(Line(points = {{6, 60}, {-8.4724, 60}, {-8.4724, 60}, {-9, 60}}, color = {255, 0, 255}));
connect(lessequalthreshold1.u, sine1.y) annotation(Line(points = {{-32, 60}, {-49.5507, 60}, {-49.5507, 60.077}, {-49.5507, 60.077}}, color = {0, 0, 127}));
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-06, Interval = 0.01));
end tmp1;
- Index
- » Users
- » arvinmor
- » Profile