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

Transpose function

Transpose function

I am having trouble getting the following parameter definition to translate properly:

parameter Real C[4,2] = cat(1, {{0,0}}, transpose({array(B * i for i in 2:4),array(A * B * i for i in 2:4)}));

The error I get is:
Error: Instantiation of array component: C failed because index modification: (C[]= = {{0.0, 0.0}}) is invalid.
    Array component: C[] has more dimensions than binding  = {{0.0, 0.0}}

Any ideas what could cause that?

Thanks!

Re: Transpose function

Your code fragment works fine for me. You would need to post a complete model.

Re: Transpose function

input Real objects_p_0 = transpose({0,20},{0,10});

error: Wrong type or wrong number of arguments to transpose({0, 20}, {0, 10}).
(in component <NO COMPONENT>).

how can I solve this one?

Re: Transpose function

bele wrote:


input Real objects_p_0 = transpose({0,20},{0,10});

error: Wrong type or wrong number of arguments to transpose({0, 20}, {0, 10}).
(in component <NO COMPONENT>).

how can I solve this one?

transpose takes a single 2-dimensional array as input, you're trying to use it with two 1-dimensional arrays instead. You probably meant transpose({{0, 20}, {0, 10}}) (note the outer { }). And you need to declare objects_p_0 as an array too of course.

Re: Transpose function

Thanks a lot @perost. It worked

There are 0 guests and 0 other users also viewing this topic
You are here: