Do we need any particular command if i need variable. If A=[1 2 3] i need this as: A=[X1 X2 X3]

댓글 수: 8

Steven Lord
Steven Lord 2017년 3월 13일
Can you say a little more about what you're trying to do, how you would use that A matrix later in your code?
Anticipating that, most likely this isn't the way to proceed; see the section "Alternatives to the eval Function" at
doc eval
particularly the second, "Variables with Sequential Names"
kritika adhikari
kritika adhikari 2017년 3월 14일
편집: Walter Roberson 2017년 3월 14일
I am writing a program where I need matrix with its element in variable form. I cannot do it directly just by writing variable inside the matrix. I need to create program for that. I tried this way but does not work
int_data=[4 2 1 5 6 3]
for i=1:6
t=int_data(i)
y(i)=X(t)
end
KSSV
KSSV 2017년 3월 14일
what you are trying to do is not clear.
kritika adhikari
kritika adhikari 2017년 3월 14일
hello I need a matrix with variable in it.
ES
ES 2017년 3월 14일
From what I understand from your code, you can simply put
y = X (int_data);
If this is not what you need, Please say what are your inputs and outputs? The code you have provided is not enough!
kritika adhikari
kritika adhikari 2017년 3월 14일
Actually m designing an interleaver. So what I need is to pass the blocks of message. That messages are in variable form . The interleaver will be constructed in such a way that the messages that has been passed will appear in matrix form with variables but not with binary digits.
Walter Roberson
Walter Roberson 2017년 3월 14일
Well, then what I posted will allow you to do that. You should go ahead and try and see if it works for your needs.
I think you are making a mistake, though. The output from an interleaver would normally be symbols, not variables. For practical purposes, the symbols would normally be encoded as non-negative integers that could be used as indices.

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

 채택된 답변

Walter Roberson
Walter Roberson 2017년 3월 14일

0 개 추천

int_data=[4 2 1 5 6 3]
X = sym('X', [1, max(int_data)]);
y = X(int_data);
The result would be
y = [X4 X2 X1 X5 X6 X3]

댓글 수: 1

kritika adhikari
kritika adhikari 2017년 3월 18일
Yeah I got It. Actually you were right. The output from interleaver are not variables. Thank you so much.

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

추가 답변 (1개)

ES
ES 2017년 3월 14일
편집: ES 2017년 3월 14일

0 개 추천

From what I understand from your code, you can simply put
y = X (int_data);
[ Example:
X = [2,4,6,8,10,12,14,16,18]
int_data=[4 2 1 5 6 3];
disp(X(int_data));
>> 8 4 2 10 12 6
]
If this is not what you need, Please say what are your inputs and outputs? The code you have provided is not enough!

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by