Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

Transpose vector or array

0 votes

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


asked May 22, 2021 by Yasir (14 points)
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?

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.

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
I need this transpose of 1D array or vector then after to compute another variables
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


Can you post example model files that show what you are trying to do?
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.



Please log in or register to answer this question.