Can I define variable in matlab?

2 Ansichten (letzte 30 Tage)
kritika adhikari
kritika adhikari am 13 Mär. 2017
Kommentiert: kritika adhikari am 18 Mär. 2017
Do we need any particular command if i need variable. If A=[1 2 3] i need this as: A=[X1 X2 X3]
  8 Kommentare
kritika adhikari
kritika adhikari am 14 Mär. 2017
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 am 14 Mär. 2017
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Mär. 2017
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 Kommentar
kritika adhikari
kritika adhikari am 18 Mär. 2017
Yeah I got It. Actually you were right. The output from interleaver are not variables. Thank you so much.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

ES
ES am 14 Mär. 2017
Bearbeitet: ES am 14 Mär. 2017
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!

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by