number to variables in matrix

조회 수: 2 (최근 30일)
TT
TT 2014년 9월 27일
댓글: Star Strider 2014년 9월 27일
Dear all,
How can I apply below numbers to the specific matrix defined with respect to variable?
For example,
U=[x , 2*x];
And, we want to apply below numbers which are in matrix form:
X1=[0 1];
X2=[2 3];
Thanks

답변 (2개)

Star Strider
Star Strider 2014년 9월 27일
I am not certain I understand what you want to do, so here are two possibilities, both using anonymous functions:
The first treats ‘x’ as a discrete single argument:
U1= @(x) [x , 2*x]; % Vector ‘x’
X1=[0 1];
X2=[2 3];
U1X1 = U1(X1)
U1X2 = U1(X2)
producing:
U1X1 =
0 1 0 2
U1X2 =
2 3 4 6
The second uses each element of ‘x’ separately:
U2 = @(x) [x(1) , 2*x(2)]; % Separate Elements of ‘x’
U2X1 = U2(X1)
U2X2 = U2(X2)
producing:
U2X1 =
0 2
U2X2 =
2 6
  댓글 수: 6
TT
TT 2014년 9월 27일
Why?!
I obtain U as function of x but in matrix. Now, I just want to apply X1 and X2 's first column to the first column of U and X1 and X2 's second column on second column of U? I just could not write a code! it did not answer.
Star Strider
Star Strider 2014년 9월 27일
‘U’ is not a matrix. It is a row vector ‘ne’ elements long.

댓글을 달려면 로그인하십시오.


dpb
dpb 2014년 9월 27일
Sorry, I can't interpret what you're after...are the Xn intended to become the factors in U, respectively? If that's so, then simply
U=[X1 2*X2];

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by