Using fprintf for matrix
715 次查看(过去 30 天)
显示 更早的评论
I have a matrix with 300 rows and 2 columns. For instance:
1 2
2 4
5 6
and another matrix with 300 rows and 1 column: for instance:
1
3
4
I want to convert them in the following:
-1: 1 2
-3: 2 4
-4: 5 6
It would be appreciated if you could help me. Thanks
0 个评论
采纳的回答
更多回答(1 个)
Ambrish Raghav
2020-7-30
X = [1,2;2,4;5,6];
>> Y = [1;3;4];
>> fprintf('-%d: %d %d\n', [Y,X].')
-1: 1 2
-3: 2 4
-4: 5 6
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!