Question in creating variables.

How do i create variables in each iteration? like x_1 to x_n and then assigning values/arrays to each of them.

4 Kommentare

Andrei Bobrov
Andrei Bobrov am 30 Sep. 2012
doc for
Matt J
Matt J am 30 Sep. 2012
I think you already asked this question (and got satisfactory answers) here:
Portgas Ace
Portgas Ace am 30 Sep. 2012
not answered. :( because i have to show 'A1' , 'A2', 'A3' to 'An' in my output. which will be determined depending on the initialization.
Portgas Ace
Portgas Ace am 30 Sep. 2012
output should look like this
A1---------3---------5---------6
A2---------5---------3---------4
A3---------6---------7---------9
(sorry for using -, spaces dont work)

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Matt J
Matt J am 30 Sep. 2012

0 Stimmen

I would do something like this:
labels=arrayfun(@(i) ['A' num2str(i)], 1:3,'uni',0).';
data=cellfun(@(a) num2str(a), num2cell(A),'uni',0);
result=[labels, data]
result =
'A1' '3' '5' '6'
'A2' '5' '3' '4'
'A3' '6' '7' '9'

1 Kommentar

Portgas Ace
Portgas Ace am 30 Sep. 2012
thank you :D ive done something simple to understand but a bit longer.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by