# Transpose vector or array

**URL:** https://forum.plexim.com/t/transpose-vector-or-array/1029
**Category:** PLECS
**Tags:** \#script, \#plecs
**Created:** [May 21, 2021, 6:46pm UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029 "2021-05-21T18:46:26Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Yasir](https://avatars.discourse-cdn.com/v4/letter/y/9f8e36/32.png) [@Yasir](https://forum.plexim.com/u/Yasir)
#### Post date: [May 21, 2021, 6:46pm UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029/1 "2021-05-21T18:46:26Z")

</div>

Hello

I want to Transpose sine-wave data in c-script, the sine-wave equation is:

X = 200_sin(2_pi_50_t), where t, is Time already defined, usually in matlab used this character ( ’ ) to transpose vector or array. So is that possible to do in plecs c-script

Thanks

---

<div class="post-metadata">

### Author: ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)
#### Post date: [May 24, 2021, 3:20pm UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029/2 "2021-05-24T15:20:57Z")

</div>

Did you consider loading the matrix data in an initialization script, and transposing the time vector there, prior to being passed to the C-Script block as a Parameter?

---

<div class="post-metadata">

### Author: ![Bryan\_Lieblick](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/bryan_lieblick/32/10_2.png) [@Bryan\_Lieblick](https://forum.plexim.com/u/Bryan_Lieblick)
#### Post date: [May 24, 2021, 3:25pm UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029/3 "2021-05-24T15:25:23Z")

</div>

This is a general C question.

1D C arrays or vectors do not need to be transposed as there is not a distinction between a [1xN] or [Nx1] like in MATLAB/Octave.

If you have a higher order matrix, then you can use for loops and re-indexing. There are plenty of code examples available elsewhere for this.

Note that oftentimes in PLECS C-Scripts, one would not use an array of time values, but rather the CurrentTime macro, which reports the simulation time as a single C double.

---

<div class="post-metadata">

### Author: ![Yasir](https://avatars.discourse-cdn.com/v4/letter/y/9f8e36/32.png) [@Yasir](https://forum.plexim.com/u/Yasir)
#### Post date: [May 25, 2021, 12:19pm UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029/4 "2021-05-25T12:19:11Z")

</div>

once I implement the x equation in matlab, the data inside x is (1 x 2000) by using this character (') the data will become (2000 x 1), I want to do the same in plecs c-script

---

<div class="post-metadata">

### Author: ![Yasir](https://avatars.discourse-cdn.com/v4/letter/y/9f8e36/32.png) [@Yasir](https://forum.plexim.com/u/Yasir)
#### Post date: [May 25, 2021, 12:21pm UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029/5 "2021-05-25T12:21:16Z")

</div>

I need this transpose of 1D array or vector then after to compute another variables

---

<div class="post-metadata">

### Author: ![Yasir](https://avatars.discourse-cdn.com/v4/letter/y/9f8e36/32.png) [@Yasir](https://forum.plexim.com/u/Yasir)
#### Post date: [May 26, 2021, 7:08am UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029/6 "2021-05-26T07:08:41Z")

</div>

Dear Kris,

the input signal to c-script is sinewave , and i want to transpose from (1 x2000) to (2000 x 1)

please help me with this problem

thanks

---

<div class="post-metadata">

### Author: ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)
#### Post date: [May 26, 2021, 1:34pm UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029/7 "2021-05-26T13:34:18Z")

</div>

Can you post example model files that show what you are trying to do?

---

<div class="post-metadata">

### Author: ![Yasir](https://avatars.discourse-cdn.com/v4/letter/y/9f8e36/32.png) [@Yasir](https://forum.plexim.com/u/Yasir)
#### Post date: [May 26, 2021, 7:09pm UTC](https://forum.plexim.com/t/transpose-vector-or-array/1029/8 "2021-05-26T19:09:44Z")

</div>

Dear Kris

thank you for your reply

I want to transpose the sinewave signal which is the input of C-Script block as shown in the attach model, for more information you can look into matlab code.

Thanks

[JA\_Model.m](https://forum.plexim.com/uploads/short-url/skZ4XMCaXBrGrIZeYxV0F8mSN5F.m) (1.53 KB)

[Jiles Atherton.plecs](https://forum.plexim.com/uploads/short-url/tVbxcRtS7zi8FZ3EpIQIaQWMTXE.plecs) (16.2 KB)
