converting matrix into semicolon separated dataset

7 ビュー (過去 30 日間)
shailesh khaire
shailesh khaire 2013 年 2 月 25 日
Well..i am new here in MATLAB. I want to know if i have a matrix how can i create a data set of values separated with semicolon (used to differentiate rows) from that same matrix?
e.g if d =
4 5 5 7
6 5 4 6
5 4 4 7
7 5 4 6
now how can i write d = [4 5 5 7; 6 5 4 6; 5 4 4 7; 7 5 4 6] again? is there any function to do this in matlab?

回答 (3 件)

the cyclist
the cyclist 2013 年 2 月 25 日
d = reshape(d,[4,4]);
  1 件のコメント
shailesh khaire
shailesh khaire 2013 年 2 月 25 日
Thanks for the reply sir. But it has not worked the way i want to. Actually, i ended up getting a matrix C having 4 rows and 250 columns. Now i want to create a data set for C which should be in the format d = [4 5 5 7; 6 5 4 6; 5 4 4 7; 7 5 4 6;......] and i will be using this C in some other function.

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


Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 25 日
編集済み: Azzi Abdelmalek 2013 年 2 月 25 日
s='['
For k=1:size(d,1)
s=[s num2str(d(k,:)) ';']
end
s(end)=']'

Walter Roberson
Walter Roberson 2013 年 2 月 25 日
s = mat2str(d);
  2 件のコメント
shailesh khaire
shailesh khaire 2013 年 2 月 25 日
Thanks for the reply. It has created the data set but not separated by semicolons which represents the ROWS...
Walter Roberson
Walter Roberson 2013 年 2 月 25 日
編集済み: Walter Roberson 2013 年 2 月 25 日
Please check again.
>> d = [4 5 5 7; 6 5 4 6; 5 4 4 7; 7 5 4 6]
d =
4 5 5 7
6 5 4 6
5 4 4 7
7 5 4 6
>> mat2str(d)
ans =
[4 5 5 7;6 5 4 6;5 4 4 7;7 5 4 6]
Note that this is a string, as the semi-colons are just an input notation that d not exist in the internal representation.

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by