Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)

Forgot password? | Forgot username? | Register
• Index
• » Users
• » Onder
• » Profile

## Posts

Apr-05-12 16:54:11
Error in b/sum(b)

Thanks for your help Perost. I am trying to generate a Modelica Custom Component for MapleSim. Do you think when you sorth this problem out, I will be able to run this in MapleSim? I returned this as a "model"  rather than "function" as below;

model basisFunction
extends Maplesoft.Icons.CustomComponent;
parameter Real x[2,1] "The input from multibody system";
Real bPen[sn*sn] "The normalized output for the basis function";
Integer sn=5 "The number of samples in each axist";
Real c[2,1] "Centre of each basis";
Real bFunc[sn*sn] "The basis function";
Real theta_r=linspace(-0.02,0.02,sn) "Generates sn values for position";
Real theta_p=linspace(-0.1,0.1,sn) "Generates sn values for velocity";
Real s[1,2]=[(theta_r[2]-theta_r[1])/1.7, (theta_p[2]-theta_p[1])/1.7];
Modelica.Blocks.Interfaces.RealInput x[2,1] annotation (Placement(transformation(
extent = {
{-110, 32},
{-90, 52}},
rotation = 0)));
Modelica.Blocks.Interfaces.RealOutput bPen[sn*sn] annotation (Placement(transformation(
extent = {
{-110, -51},
{-90, -31}},
rotation = 0)));
equation
for i in 1:size(theta_r,1) loop
for j in 1:size(theta_p,1) loop
c=[theta_r[i]; theta_p[j]];
bFunc[(i-1)*size(theta_r,1)+j]=scalar(exp(-((1.0./s).^2)*(x-c).^2));
end for;
end for;
bPen=bFunc/sum(bFunc);
annotation (uses(Modelica(version = "3.1")));
end basisFunction;

This has not worked. Can you see any clear mistake here?

Thanks again...

Apr-04-12 21:40:00
Error in b/sum(b)

Hi,

Thanks for your help. I am using version 1.8.1, I think this is the latest version. I call the function "basisFunction([0.01; 0.1])". Actually, I am trying to generate a Modelica Custom Component to use in MapleSim, but I just wanted to test the function in Modelica before. Maybe this might work if I write this there. I will try and let you know if this works there.

Again thanks for your help

Apr-04-12 18:14:20
Error in b/sum(b)

Hi all,
I wrote a function and I have this error, "Failed to elaborate expression: bFunc / sum(bFunc)". If you notice my mistake, could you let me know please. Thanks. The function is:

function basisFunction
input Real x[2,1];
output Real bPen[sn*sn];
protected Integer sn:=5 "The number of the points in each axis";
Real c[2,1];
Real bFunc[sn*sn];
Real theta_r[sn]:=linspace(-0.02,0.02,sn) "Generates sn values for position";
Real theta_p[sn]:=linspace(-0.1,0.1,sn)   "Generates sn values for velocity";
Real s[1,2]:=[(theta_r[2]-theta_r[1])/1.7, (theta_p[2]-theta_p[1])/1.7]    "Determine the size of the basis function";
// Calculate the basis function response
algorithm
for i in 1:size(theta_r,1) loop
for j in 1:size(theta_p,1) loop
c:=[theta_r[i]; theta_p[j]]  "Centre of each basis";
bFunc[(i-1)*size(theta_r,1)+j]:=scalar(exp(-((1.0./(s)).^2)*((x-c).^2)));
end for;
end for;
bPen:=bFunc/sum(bFunc);
end basisFunction;

Apr-02-12 14:39:44
Too many equations, overdetermined system. Error

Thanks Adrian, I looked at those documents before and this is my first algorithm in Modelica. I initially wrote it as a function with algorithm but I am trying to generate a "Modelica Custom Component" for a MapleSim application; hence I am just trying to adapt it into MapleSim.

Thanks for your suggestions...

Mar-31-12 22:11:12
Too many equations, overdetermined system. Error

Hi All,

I am tyring to write a Modelica code and I have this error "Too many equations, overdetermined system.The model has 126 equation(s) and 26 variable(s)". My code is;

model basisFunction
parameter Integer sn=5 "The number of the points in each axis";
parameter Integer i=1;
parameter Integer j=1;
parameter Real c[2,1]=[0.1; 0.2];
parameter Real theta_r[sn]=linspace(-0.02,0.02,sn) "Generates sn values for position";
parameter Real theta_p[sn]=linspace(-0.1,0.1,sn)   "Generates sn values for velocity";
parameter Real s[1,2]=[(theta_r[2]-theta_r[1])/1.7, (theta_p[2]-theta_p[1])/1.7]    "Determine the size of the basis function";
parameter Real bFunc[sn*sn]=fill(1,sn*sn);
input Real x[2,1]=[0.01; 0.09];
output Real bPen[sn*sn]=fill(1,sn*sn);
// Calculate the basis function response
equation
for i in 1:size(theta_r,1) loop
for j in 1:size(theta_p,1) loop
c=[theta_r[i]; theta_p[j]]  "Centre of each basis";
bFunc[(i-1)*size(theta_r,1)+j]=scalar(exp(-((1.0./(s)).^2)*((x-c).^2)));
end for;
end for;
bPen=bFunc/sum(bFunc);
end basisFunction;

if you are able to help me, I will be very pleased. Also if you know how I can plot "bPen" here, please let me know...

Best

Mar-31-12 22:01:41
Type mismatch error

Thank you I think I saw my mistake...

Mar-31-12 18:35:57
Type mismatch error

Hi all,

I have a type mismatch error in my modelica code;

model basisFunction
parameter Integer sn=5 "The number of the points in each axis";
parameter Integer i=1;
parameter Integer j=1;
parameter Real c[2,1]=[0; 0];
parameter Real theta_r[sn]=linspace(-0.02,0.02,sn) "Generates sn values for position";
parameter Real theta_p[sn]=linspace(-0.1,0.1,sn)   "Generates sn values for velocity";
parameter Real s[1,2]=[(theta_r[2]-theta_r[1])/1.7, (theta_p[2]-theta_p[1])/1.7]    "Determine the size of the basis function";
parameter Real bFunc[sn*sn]=fill(1,sn*sn);
parameter Real x[2,1]=[0.01; 0.09];
parameter Real bPen[sn*sn]=zeros(sn*sn);
// Calculate the basis function response
equation
for i in 1:size(theta_r,1) loop
for j in 1:size(theta_p,1) loop
c=[theta_r[i]; theta_p[j]]  "Centre of each basis";
bFunc[(i-1)*size(theta_r,1)+j]=exp(-((1.0./(s)).^2)*((x-c).^2));
end for;
end for;
bPen=bFunc/sum(bFunc);
end basisFunction;

and the error mesage is ;

Error: Type mismatch in equation t[1]={{(1.0 / s[1,1]) ^ 2.0 * (x[1,1] - c[1,1]) ^ 2.0 + (1.0 / s[1,2]) ^ 2.0 * (x[2,1] - c[2,1]) ^ 2.0}} of type Real=Real[1, 1]
Error: Error occurred while flattening model basisFunction.

Could you help me to fix this problem please?
Thanks

• Index
• » Users
• » Onder
• » Profile
You are here: