Transpose a matrix when using eval

12 views (last 30 days)
Kyriacos
Kyriacos on 21 Mar 2012
Edited: per isakson on 16 Feb 2017
Hello,
I have a programming question. Effectively, I am not sure how I could use the transpose of a vector/matrix within an "eval" command since transposing involves the sign " ' ". What I mean: I want to execute the following command:
ARp0(1,:)= autoreg(var1_0(1, :)',pl, 1) ;
It does not really matter what it means, just note that I use the row-vector var1_0(1,:) which is transposed to give me a column vector. Now, I want to execute that using "eval" so that it automatically adjusts the zeros in the variable names (for some variable k). That would be:
eval[('ARp', num2str(k), '(1,:)= autoreg(var1_', num2str(k), '(1, :)',pl, 1)']) ;
You see that the " ' " sign (just before pl) is meant to be the transpose-sign, but it intervenes with the eval function.
How can I cope with this problem? Thanks!
Kyriacos

Accepted Answer

Friedrich
Friedrich on 21 Mar 2012
Hi,
you can do it like this:
eval('ARp0(1,:)= autoreg(var1_0(1, :)'',pl, 1);')
Or use the transpose function:
eval('ARp0(1,:)= autoreg( transpose(var1_0(1, :)),pl, 1);')
  2 Comments
Daniel Shub
Daniel Shub on 21 Mar 2012
Technically ' is ctranspose and .' is transpose.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!