Transpose a matrix when using eval
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kyriacos
am 21 Mär. 2012
Bearbeitet: per isakson
am 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
0 Kommentare
Akzeptierte Antwort
Friedrich
am 21 Mär. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!