How to put the values into adjacent matrix?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Beibit Sautbek
am 3 Jul. 2016
Beantwortet: Geoff Hayes
am 3 Jul. 2016
I have matrix A=[2,2; 4,2; 3,4; 3,1]. The first column represents x axis, the second column represents y axis of the points. So I have 4 points. And I need make adjacent matrix of x elements of points. So, A=[x1,x2,x3,x4]=>A=[2,4,3,3]
How to make adjacent matrix like this?:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154652/image.png)
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 3 Jul. 2016
Beibit - it seems that the second column of your matrix A is ignored, so the code would just be
A=[2,2; 4,2; 3,4; 3,1];
adjMat = zeros(4,4);
for u=1:4
for v=1:4
adjMat(v,u) = A(u,1)-A(v,1);
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!