Using fprintf for matrix
Show older comments
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
Accepted Answer
More Answers (1)
Ambrish Raghav
on 30 Jul 2020
0 votes
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
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!