give name to value in row

3 ビュー (過去 30 日間)
paul kaam
paul kaam 2015 年 5 月 18 日
コメント済み: paul kaam 2015 年 5 月 18 日
Hi everyone,
say i have a row like this:
a= [1 2 3 4];
and I want each value to get its own name like this:
time = 1 bb = 2 fk = 3 ww = 4
I thought by doing it like this:
[time bb fk ww] = a;
but apprently that does not work
hope u can help it's probably easy but i guess not for me :)
thanks in advance!
Paul

回答 (2 件)

Walter Roberson
Walter Roberson 2015 年 5 月 18 日
You might want to use table()
  1 件のコメント
paul kaam
paul kaam 2015 年 5 月 18 日
Thanks!

サインインしてコメントする。


Stephen23
Stephen23 2015 年 5 月 18 日
編集済み: Stephen23 2015 年 5 月 18 日
If you want to allocate multiple values at once then you can use deal:
>> a = [1 2 3 4];
>> b = num2cell(a);
>> [time,bb,fk,ww] = deal(b{:})
time =
1
bb =
2
fk =
3
ww =
4
Or you could simply allocate them explicitly:
>> time = a(1), bb = a(2), fk = a(3), ww = a(4)
time =
1
bb =
2
fk =
3
ww =
4
  1 件のコメント
paul kaam
paul kaam 2015 年 5 月 18 日
Thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by