I have tried following code for creating sparse graph in MATLAB:
cm = sparse([1 1 2 2 3 3 4 5],[2 3 4 5 4 5 6 6],...
[2 3 3 1 1 1 2 3],6,6)cm =
You shouldn't write the cm =
part at the end. That is, when you write
cm = sparse([1 1 2 2 3 3 4 5],[2 3 4 5 4 5 6 6],...
[2 3 3 1 1 1 2 3],6,6)
on the command line, you will get
cm =
(1,2) 2
(1,3) 3
(2,4) 3
(3,4) 1
(2,5) 1
(3,5) 1
(4,6) 2
(5,6) 3
This is because, you didn't write a semicolon at the end of the statement. If you don't want to see the value of cm
, just add a semicolon after the closing the parentheses. In addition ...
tells to write multi-line statement. You can write
cm = sparse([1 1 2 2 3 3 4 5],[2 3 4 5 4 5 6 6],[2 3 3 1 1 1 2 3],6,6)
alternatively.