converting matrix into semicolon separated dataset
7 views (last 30 days)
Show older comments
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?
0 Comments
Answers (3)
Azzi Abdelmalek
on 25 Feb 2013
Edited: Azzi Abdelmalek
on 25 Feb 2013
s='['
For k=1:size(d,1)
s=[s num2str(d(k,:)) ';']
end
s(end)=']'
0 Comments
Walter Roberson
on 25 Feb 2013
s = mat2str(d);
2 Comments
Walter Roberson
on 25 Feb 2013
Edited: Walter Roberson
on 25 Feb 2013
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!